pombreda / pgreloaded

Automatically exported from code.google.com/p/pgreloaded
Other
0 stars 0 forks source link

Fix examples/audioplayer.py #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.cp -r lib pygame2
2.PYTHONPATH=. python examples/audioplayer.py 

What is the expected output? What do you see instead?
Traceback (most recent call last):
  File "examples/audioplayer.py", line 7, in <module>
    from pygame2.examples import RESOURCES
ImportError: No module named examples

What version of the product are you using? On what operating system?
pygreloaded HEAD

Please provide any additional information below.
Attached patch fixes that.

Original issue reported on code.google.com by techtonik@gmail.com on 16 Jul 2012 at 8:23

Attachments:

GoogleCodeExporter commented 9 years ago
Due to the source directory layout, pygame2.examples is not in place (yet). 
Please install the package properly.

Original comment by marcusvonappen@googlemail.com on 16 Jul 2012 at 8:44

GoogleCodeExporter commented 9 years ago
I don't understand how installing the package will make RESOURCES an importable 
package. Does it work for you?

Original comment by techtonik@gmail.com on 17 Jul 2012 at 4:08

GoogleCodeExporter commented 9 years ago
audioplayer.py expects a package "pygame2.examples", from which RESOURCES can 
be imported. The package is based on the examples/ folder. Once you install 
pgreloaded, the package will be available for usage.

Original comment by marcusvonappen@googlemail.com on 17 Jul 2012 at 4:38

GoogleCodeExporter commented 9 years ago
Now I see. Why do you need this hack anyway? It complicates things without any 
real benefit, or do I fail to see one?

Why my patch is not worthy for inclusion? It fixes the issue for me and doesn't 
change anything for you.

Original comment by techtonik@gmail.com on 17 Jul 2012 at 4:47

GoogleCodeExporter commented 9 years ago
One of the main reasons is that many users tend to copy and modify things in a 
local directory, causing the example to break.
Another is that the example shall have feature the bare minimum of code, while 
still working, when executed in a typical installation scenario.

Although your patch only contains a few lines of code, it introduces other 
things to explain in the example, which might draw away the user's attention; 
this should be avoided whenever possible.

The main focus of the examples (at least those aiming to teach the basics of 
pgreloaded) is to provide essential information about the parts they 
demonstrate without adding additional overhead.

Original comment by marcusvonappen@googlemail.com on 17 Jul 2012 at 5:00

GoogleCodeExporter commented 9 years ago
I don't think anybody will go through the hassle of searching and copying 
examples from /usr/lib/python2.6/whatever instead of just downloading them from 
the web and unpacking the archive.

I find `from pyglet.examples import RESOURCE` far more confusing and mysterious 
than explicit Resources usage example, which users who load data need to learn 
anyway. Now that issue #13 is closed the patch can be even more simplified.

It's ok if people looking into advanced examples such as audioplayer.py should 
be familiar with resources concept first. It is reasonable, and easily 
explained and doesn't conflict with common sense.

Original comment by techtonik@gmail.com on 17 Jul 2012 at 5:16

GoogleCodeExporter commented 9 years ago
You are right, users will unpack and install it (or install it via their 
system's package management), copy the file from the examples directory and use 
it elsewhere in a completely different location - not always but often enough.

Since users are required to install the package beforehand anyways (otherwise 
they are unable to even import pygame2 cleanly), there is no necessity to add 
more code than necessary to the examples.

Original comment by marcusvonappen@googlemail.com on 17 Jul 2012 at 6:51

GoogleCodeExporter commented 9 years ago
I is it ok for you when users copy the examples, use them, copy they own files 
into example resources directory and then become totally confused that these 
new files can't be found?

I'd keep "installation requirements" and "example clarity" concepts orthogonal. 
Then your argument reads as: "minimal code" in examples is better than "clear 
code".

Original comment by techtonik@gmail.com on 22 Jul 2012 at 5:47

GoogleCodeExporter commented 9 years ago
Should I say once more that awesome fix for issue #13 makes it a one line bloat 
lose for a whole installation magic clarity win.

Original comment by techtonik@gmail.com on 22 Jul 2012 at 5:49