Hello, Jeff Hardy ). 1) It is a good reference. But the methods must be defined in advance (class A). If I write ttt ('i') without defining it in the class A, I get an error. Use __getattr__ in class A does not work.
class A(object): def salutation(self, accusative): # code def farewell(self, greeting, accusative): # code ...................... salutation("world") farewell("goodbye", "world") ttt('yy') name 'ttt' is not defined. 2) A good option would be: 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 (((. > The short answer is that you can't, in any version of Python. > > The longer answers can be found at > http://stackoverflow.com/questions/2447353/getattr-on-a-module. > > - Jeff > > On Mon, Sep 17, 2012 at 10:17 AM, <sepa...@sibmail.com> wrote: >> Hello, Vernon Cole. >> Or you probably do not understand the question, or I did not properly >> posed the question. >> I know I can define a function (ttt). And if I'm interested in __ >> getattr__, so in this case it can not be determined, or its name and >> parameters are defined at run time. >> Thank you. >> >>> Dear Sir: >>> Sorry, your question does not seem to make sense. >>> Your example appears to be a simple function call with one keyword >>> argument. To use it, you simply define the optional arguments when you >>> define the function. See the documentation at: >>> http://docs.python.org/tutorial/controlflow.html#more-on-defining-functions >>> >>> __getattr__ is only used within classes to emulate methods which do >>> not >>> actually exist. That does not appear to be what you are wanting. >>> -- >>> Vernon Cole >>> >>> On Mon, Sep 17, 2012 at 4:42 AM, <sepa...@sibmail.com> wrote: >>> >>>> Hello. >>>> For example in the text of the module meets the command: >>>> ttt(4, x = 7) >>>> where and how to define __ getattr__ to handle it? >>>> Thank you. >>>> >>>> _______________________________________________ >>>> Ironpython-users mailing list >>>> Ironpython-users@python.org >>>> http://mail.python.org/mailman/listinfo/ironpython-users >>>> >>> >> >> >> _______________________________________________ >> Ironpython-users mailing list >> Ironpython-users@python.org >> http://mail.python.org/mailman/listinfo/ironpython-users > _______________________________________________ Ironpython-users mailing list Ironpython-users@python.org http://mail.python.org/mailman/listinfo/ironpython-users