[Tutor] class.__repr__: 'str' object is not callable???
pan@uchicago.edu
pan@uchicago.edu
Wed Apr 30 23:38:01 2003
Can someone tell me what the hell is happening in the
following code?
Why __getattr__ gets called when the __repr__ is the actual
one that I called?
Why is the ['str' object is not callable] happen ??
thx in advance.
pan
>>> class aClass:
.. def __init__(self):pass
.. def __repr__(self):
.. return 'this is aClass'
.. def __getattr__(self, name):
.. print 'getting attr' #<==== [A]
.. return 'returned value'
..
>>>
>>> a=aClass()
>>> a
this is aClass
>>> print a
getting attr
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: 'str' object is not callable
>>>