steven.bethard at gmail.com
Mon Sep 11 15:59:23 CEST 2006
> Is there any reason NOT to do this that I may be unaware of?
> # ----------- Module 2.py ------------
> # 'Self' module processing
> import sys
> var = 0
> self = sys.modules[__name__]
> def MyRoutine():
> self.var = 1
> print var
Looks basically fine to me, but I'd probably write it as::
_self = __import__(__name__)
Then you don't need to import sys. I'd also use a leading underscore
for "self" so that it's clearly marked as a module-internal attribute.
More information about the Python-list