__getattr__ possible loop

Maksim Kasimov maksim.kasimov at gmail.com
Thu Dec 28 12:01:44 EST 2006


Chris Mellon wrote:
> 
> Nothing so clever. dir() eats and ignores all exceptions, so when you
> hit the recursion limit it eats the RecursionLimitExceeded exception
> and continues merrily along the way. This is probably not good
> behavior...
> 
> class Foo:
>    def __getattr__(self, attr):
>        raise SystemExit, "Don't call me, again, ever"
> 
> f = Foo()
> f.method() #dies correctly
> dir(f) #continues happily

can't understand - what kind of problem you tried to fix in that way?
if __getattr__ just raise some exception, it needless to define it at all.

-- 
Maksim Kasimov



More information about the Python-list mailing list