[IPython-user] strange repeated call to getattr

John Hunter jdh2358@gmail....
Fri Jun 20 10:12:48 CDT 2008

We noticed that getattr is called repeatedly in ipython in the example below:

# getattr_test.py
class Foo:

   count = 0

   def __getattr__(self, attr):
       Foo.count += 1
       print "%d attr" % Foo.count

foo = Foo()
print foo.jdh

### now from ipython:

In [2]: run /home/titan/johnh/getattr_test.py
1 attr

In [3]: foo.jdh
2 attr
3 attr

On line 3 getattr is called twice.  Is this expected?

IPython 0.9.0.bzr.r1016


More information about the IPython-user mailing list