[Python-ideas] Bring back callable()

Georg Brandl g.brandl at gmx.net
Wed Nov 24 11:59:57 CET 2010


Falls under "no new builtins" though.
Georg
Am 24.11.2010 00:19, schrieb Guido van Rossum:
> I admit defeat on this one.
>> On Tue, Nov 23, 2010 at 3:14 PM, Michael Foord
> <fuzzyman at voidspace.org.uk> wrote:
>>>>>> On 23 November 2010 23:01, Antoine Pitrou <solipsis at pitrou.net> wrote:
>>>>>> Hello,
>>>>>> 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.
>>>> +1 I find it useful in Python 2. You have to know its limitations, but it is
>> still useful.
>>>> Michael
>>>>>>>> Regards
>>>>>> Antoine.
>>>>>>>>> _______________________________________________
>>> Python-ideas mailing list
>>> Python-ideas at python.org
>>> http://mail.python.org/mailman/listinfo/python-ideas
>>>>>>>> --
>> http://www.voidspace.org.uk
>>>>>>>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>>>>>>


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /