
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. Regards Antoine.

On 23 November 2010 23:01, Antoine Pitrou <solipsis@pitrou.net> wrote:
+1 I find it useful in Python 2. You have to know its limitations, but it is still useful. Michael

On Tue, 23 Nov 2010 15:15:46 -0800 Alexandre Conrad <alexandre.conrad@gmail.com> wrote:
It's not the right code. You can take a look at the implementation of Callable.__subclasshook__ here: http://code.python.org/hg/branches/py3k/file/tip/Lib/_abcoll.py#l139 Regards Antoine.

On Tue, Nov 23, 2010 at 3:01 PM, Antoine Pitrou <solipsis@pitrou.net> wrote:
Perhaps it should also be renamed iscallable() for consistency with isinstance() and issubclass() and to free up the nice name "callable" for user use. Cheers, Chris -- http://blog.rebertia.com

On 7 March 2011 20:09, Joao S. O. Bueno <jsbueno@python.org.br> wrote:
Too late. :-)
It didn't always do exactly the right thing (but was usually "good enough") and was thought easy to replace with a more accurate alternative (isinstance(foo, abc.Callable) I *think*) which proved annoying in pactise. All the best, Michael js
-- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html

Antoine Pitrou <solipsis@...> writes:
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. Ram.

Ram Rachum wrote:
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)
::: 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/

On 23 November 2010 23:01, Antoine Pitrou <solipsis@pitrou.net> wrote:
+1 I find it useful in Python 2. You have to know its limitations, but it is still useful. Michael

On Tue, 23 Nov 2010 15:15:46 -0800 Alexandre Conrad <alexandre.conrad@gmail.com> wrote:
It's not the right code. You can take a look at the implementation of Callable.__subclasshook__ here: http://code.python.org/hg/branches/py3k/file/tip/Lib/_abcoll.py#l139 Regards Antoine.

On Tue, Nov 23, 2010 at 3:01 PM, Antoine Pitrou <solipsis@pitrou.net> wrote:
Perhaps it should also be renamed iscallable() for consistency with isinstance() and issubclass() and to free up the nice name "callable" for user use. Cheers, Chris -- http://blog.rebertia.com

On 7 March 2011 20:09, Joao S. O. Bueno <jsbueno@python.org.br> wrote:
Too late. :-)
It didn't always do exactly the right thing (but was usually "good enough") and was thought easy to replace with a more accurate alternative (isinstance(foo, abc.Callable) I *think*) which proved annoying in pactise. All the best, Michael js
-- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html

Antoine Pitrou <solipsis@...> writes:
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. Ram.

Ram Rachum wrote:
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)
::: 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/
participants (17)
-
Alexandre Conrad
-
Antoine Pitrou
-
Benjamin Peterson
-
Bill Janssen
-
Chris Rebert
-
Georg Brandl
-
Guido van Rossum
-
Joao S. O. Bueno
-
M.-A. Lemburg
-
Michael Foord
-
Michael Foord
-
MRAB
-
Ram Rachum
-
Robert Collins
-
Steven D'Aprano
-
Terry Reedy
-
Zac Burns