Jacek Generowicz <jmg at ecs.soton.ac.uk> wrote in <g0g0ggy7ct.fsf at scumbag.ecs.soton.ac.uk>: >>>> print a.__getattr__("bar") >Traceback (most recent call last): > File "<stdin>", line 1, in ? >AttributeError: 'foo' instance has no attribute '__getattr__' > > What you want is: >>> print getattr(a, "bar") 4