Why doesn't __call__ lead to infinite recursion?

bromden bromden at gazeta.pl.no.spam
Fri Aug 15 22:34:09 CEST 2003


> foo is a function
> foo is a callable object
> foo has method __call__ defined

true
true
false

even if you "setattr(foo, '__call__', another_function)"
foo.__call__ won't be called

 >>> def foo(): print 'foo'
 >>> def loo(): print 'loo'
 >>> foo.__call__ = loo
 >>> foo()
foo

-- 
bromden[at]gazeta.pl





More information about the Python-list mailing list