[Python-ideas] Why is there a callable predicate, but no iterable?

Georg Brandl g.brandl at gmx.net
Fri Sep 25 23:42:34 CEST 2009


Terry Reedy schrieb:
> Andrey Fedorov wrote:
> 
>> What is the tradeoff between hasattr(f, '__call__')
> 
> I know about that ;-)
> 
>> and isinstance(f, Callable)?
> 
> New to me ;-)
> I presume it needs an import.
> I presume it also requires that something be registered as a Callable.

Nope; it uses the new instance/subclass inquiry hooks to pretend all objects
having a __call__ attribute are instances of Callable.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.




More information about the Python-ideas mailing list