Get rid of recursive call __getattr__

Pelmen pelmenmail at mail.ru
Wed Dec 14 09:00:11 EST 2005


>>> class Test:
	  def __getattr__(self, attr):
	    print attr

	  def foo(x):
	    print x

>>> t = Test()
>>> print t
__str__

Traceback (most recent call last):
  File "<pyshell#23>", line 1, in -toplevel-
    print t
TypeError: 'NoneType' object is not callable

what i have to do? define __str__ explicitly?




More information about the Python-list mailing list