[Ironpython-users] How to use __ getattr__ to the current module?

sepatan at sibmail.com sepatan at sibmail.com
Tue Sep 18 16:28:25 CEST 2012


Hello, Jeff Hardy ).
The fact that the environment in which the plan is written mixed code.
Operators Python runtime interpreter Python, operators are redirected to a
different language version to another interpreter. It is necessary that
when code appears key word in another language, Python captured them
(__geattr__). And it needs to be implemented in the current module. I
think Python deal with it)). May have many "copies to break"))).

> On Mon, Sep 17, 2012 at 11:11 PM, <sepatan at sibmail.com> wrote:
>
>> 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.
>>
>> Correct.
> Python is telling you that 'ttt' has no meaning.
> It does not, cannot, will never, do anything else.
> This is an error in your program.
> You must do something -- either a 'def', an assignment, or an include, to
> define 'ttt' before you use it.
> __getattr__() is used to catch undefined references from code in a
> _different_ module, not your own.
> Why would you go to the trouble of writing code in your own program to fix
> errors in itself?
> --
> Vernon
>




More information about the Ironpython-users mailing list