Steve Holden wrote:
> Peter Otten wrote:
>
>> Pelmen wrote:
>>
>>
>> class Test:
>>>
>>>
>>> def __getattr__(self, attr):
>>>print attr
>>>
>>> def foo(x):
>>>print x
>>>
>>>
>> t = Test()
>> print t
>>>
>>>
>>> __str__
>>>
>>> Traceback (most
Pelmen wrote:
class Test:
>
> def __getattr__(self, attr):
> print attr
>
> def foo(x):
> print x
>
>
t = Test()
print t
>
> __str__
>
> Traceback (most recent call last):
> File "", line 1, in -toplevel-
> print t
> TypeError: 'NoneType'
Peter Otten wrote:
> Pelmen wrote:
>
>
>class Test:
>>
>> def __getattr__(self, attr):
>>print attr
>>
>> def foo(x):
>>print x
>>
>>
>t = Test()
>print t
>>
>>__str__
>>
>>Traceback (most recent call last):
>> File "", line 1, in -toplevel-
thanks, now all clear
--
http://mail.python.org/mailman/listinfo/python-list
Pelmen wrote:
> >>> class Test:
> def __getattr__(self, attr):
> print attr
>
> def foo(x):
> print x
>
> >>> t = Test()
> >>> print t
> __str__
>
> Traceback (most recent call last):
> File "", line 1, in -toplevel-
> print t
> TypeError: 'None
Pelmen wrote:
> How can I get rid of recursive call __getattr__ inside this method, if
> i need to use method or property of the class?
>
The usual mistake here is to write a __getattr__() implementation that
references an undefined self-relative name, which leads to a recursive
>>> class Test:
def __getattr__(self, attr):
print attr
def foo(x):
print x
>>> t = Test()
>>> print t
__str__
Traceback (most recent call last):
File "", line 1, in -toplevel-
print t
TypeError: 'NoneType' object is not callable
what i have to
thanks, i found the problem
--
http://mail.python.org/mailman/listinfo/python-list
as __repr__ for example?
--
http://mail.python.org/mailman/listinfo/python-list
thanks, i understood my mistake
i try to get attribute, that wasn't defined
--
http://mail.python.org/mailman/listinfo/python-list
thanks, i should been read more closely
--
http://mail.python.org/mailman/listinfo/python-list
Pelmen wrote:
> How can I get rid of recursive call __getattr__ inside this method, if
> i need to use method or property of the class?
Hi Pelmen,
Having read the docs included with my Python distribution on
__getattr__, I don't see yet how you will get recursive calls to the
meth
Pelmen wrote:
> How can I get rid of recursive call __getattr__ inside this method, if
> i need to use method or property of the class?
>
Sorry, but I don't understand your question. Which recursive calls to
__getattr__ ? __getattr__ is only called if a/ it's defined and b/ th
How can I get rid of recursive call __getattr__ inside this method, if
i need to use method or property of the class?
--
http://mail.python.org/mailman/listinfo/python-list
14 matches
Mail list logo