Newbie edit/compile/run cycle question
Diez B. Roggisch
deets at nospam.web.de
Mon Dec 10 10:25:33 EST 2007
More information about the Python-list mailing list
Mon Dec 10 10:25:33 EST 2007
- Previous message (by thread): Newbie edit/compile/run cycle question
- Next message (by thread): Newbie edit/compile/run cycle question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
MartinRinehart at gmail.com wrote: > Bruno, > > Please explain why the NOP import is a GoodThing. Use small words > please. I'm not as young as I used to be. Because otherwise every import would result in overhead without any benefit. Think of a module like this: -------- A_GLOBAL_VARIABLE = extremely_costly_initialization_of_cache_contents() -------- You only want that to happen once. > I didn't know about reload(), but now that I'm informed on that point > I'm still using > > os.remove('foo.pyc') > reload(foo) > > A single command to do that would be nice. You can create your own function that does this. def better_reload(module): import os if os.path.exists(module.__file__) and module.__file__[-3:] == 'pyc': os.remove(module.__file__) # attention - you might want more checks reload(module) Then you can put that into a file, e.g. ~/.pythonrc and point the environment-variable PYTHONSTARTUP to that file. Diez
- Previous message (by thread): Newbie edit/compile/run cycle question
- Next message (by thread): Newbie edit/compile/run cycle question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list