Extending Python: rewriting a single method in C

Duncan Booth duncan at rcp.co.uk
Wed Mar 14 05:42:09 EST 2001


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




More information about the Python-list mailing list