Obscure __getattr__ behavior
Andrew Bennetts
andrew-pythonlist at puzzling.org
Thu Feb 6 22:55:23 EST 2003
On Thu, Feb 06, 2003 at 09:48:47AM +0000, D. Herzberg wrote:
[..snip..]
> When you run the code you know for sure that __getattr__ was
> called with `__repr__' as a parameter; and you know for sure
> that the lookup was not successfull -- so, what code is next?
> Sure, it is the raise statement but for some reason it doesn't
> raise anything. What makes the treatment of __repr__ special
> once we are in the __getattr__ function?
Nothing.
Notice that your Test class has no __repr__. Regardless of the presence of
__getattr__, doing repr(t) (which is implicitly what you did interactively),
will use a default when no __repr__ is found (i.e. <module.Class instance at
0xID>).
-Andrew.
More information about the Python-list
mailing list