namespaces
Paolino
paolo_veronelli at tiscali.it
Wed Aug 10 06:28:08 EDT 2005
Scott David Daniels wrote:
> Well, an entry in the dictionary "sys.modules" is what is returned by
> imports, so you could either pre-replace or post-replace a module by
> an object which uses the descriptor technique to get to some (but not
> necessarily all) of the attributes. Think of this technique as a
> hack to get to a goal, rather than a good technique to use; good for
> debugging, not so nice for production work. If you still don't know
> how to do this from this admittedly sketchy description, I'd suggest
> you avoid trying it altogether.
>
Thanks.Is don't know if this is *the* way to wrap the module ?
import new,sys
class Free(new.module):
def __init__(self,moduleName):
new.module.__init__(self,moduleName)
assert moduleName in sys.modules
self.__dict__.update(sys.modules[moduleName].__dict__)
sys.modules[moduleName]=self
def desc(self):
pass
Free(__name__) #'no errors'
but 'desc' is not defined in this namespace.
Paolino
___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
More information about the Python-list
mailing list