How to use __getattr__ to the current module, for automatically add attributes of the real-time

sergeiiv65 at gmail.com sergeiiv65 at gmail.com
Tue Sep 18 03:52:53 EDT 2012


Want to work so:

import sys
class Foo(object):
    def __getattr__(self, t):
       print 'use __getattr__ - ', t
       return type(t, (object,), {})
    def funct1(self): pass
    def funct2(self): pass

sys.modules[__name__] = Foo()
ttt('yy')

name 'ttt' is not defined.
 __getattr__ not work (((.



More information about the Python-list mailing list