import main
def configure():
print main.window
Obviously you still need to ensure that the main() function gets
called before configure(), or you'll get an error.
hth,
-Casey
The solution is that you should not actually run the main.py module as
a script. Instead create a separate script called "run_game.py" (it
can be called anything, but that is commonplace). That script will
contain only the following:
import main
main.main()
I would probably rename the main module to "game" or something to make
it less confusing, but that's optional. You can then remove the if
__main__ conditional from the bottom of main.py entirely.
Note there is a nice python game skeleton for pyglet that uses this
pattern. It was made for pyweek, but is useful as a starter template.
I intend to add a skeleton templating system to grease so that you can
run a script to generate the modules, scripts, and basic configuration
for some different games. That will hopefully help prevent these sorts
of problems.
You can find the skeleton here, I recommend it:
http://media.pyweek.org/static/skellington-1.9.zip
-Casey