[issue7006] The replacement suggested for callable(x) in py3k is not equivalent

Milko Krachounov report at bugs.python.org
Sun Sep 27 18:08:31 CEST 2009


Milko Krachounov <python at milko.3mhz.net> added the comment:

My suggestion is not only unreadable, but wrong. It's even less accurate
than hasattr(x, '__call__'), as it doesn't look in all the classes in
the MRO. Using isinstance(x, collections.Callable) should probably be
the correct replacement for 2to3 and situation where checking this is
really needed, as it does look for __call__ in the whole MRO.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7006>
_______________________________________


More information about the Python-bugs-list mailing list