[Python-ideas] Bring back callable()

M.-A. Lemburg mal at egenix.com
Wed Nov 24 11:59:34 CET 2010


Ram Rachum wrote:
> Antoine Pitrou <solipsis at ...> writes:
>> Python 3 has removed callable() under the justification that's it's not
>> very useful and duck typing (EAFP) should be used instead. However,
>> it has since been felt by many people that it was an annoying loss;
>> there are situations where you truly want to know whether something is a
>> callable without actually calling it (for example when writing
>> sophisticated decorators, or simply when you want to inform the user
>> of an API misuse).
>>
>> The substitute of writing `isinstance(x, collections.Callable)` is
>> not good, 1) because it's wordier 2) because collections is really not
>> an intuitive place where to look for a Callable ABC.
>>
>> So, I would advocate bringing back the callable() builtin, which was
>> easy to use, helpful and semantically sane.
>>
>> Antoine.
> 
> I actually really prefer `isinstance(x, collections.Callable)`...
>
> If this was accepted, I would at least want it to be called `iscallable` instead 
> of `callable`, since I sometimes want to use the name `callable` in my code.

That's still possible. callable() is a built-in function,
not a keyword.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 24 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the Python-ideas mailing list