[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-28 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8e57b5d8f58f by Florent Xicluna in branch '3.2': Closes #13258: Use callable() built-in in the standard library. http://hg.python.org/cpython/rev/8e57b5d8f58f -- nosy: +python-dev resolution: -> fixed stage: patch review -> committed/rejec

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-25 Thread Éric Araujo
Éric Araujo added the comment: This change is fine for packaging. In the 2.x backport I already use callable (and damn the py3k warning) and the 3.x backport uses the incorrect hasattr(inst, '__call__'); I’ll change that to use a backported d2.compat.callable. -- _

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread STINNER Victor
STINNER Victor added the comment: > Is it actually appropiate to commit this to 3.2? If it fixes a bug, the fix should be backported to 3.2. -- ___ Python tracker ___ _

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread Jesús Cea Avión
Jesús Cea Avión added the comment: Is it actually appropiate to commit this to 3.2?. I am neutral to it, just asking. -- nosy: +jcea ___ Python tracker ___

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread Florent Xicluna
Florent Xicluna added the comment: We have so many alternatives, it's funny ... def callable(obj): return hasattr(obj, '__call__') or hasattr(obj, '__bases__') def callable(obj): return isinstance(obj, collections.abc.Callable) def callable(obj): return hasattr(obj, '__call__') o

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread STINNER Victor
STINNER Victor added the comment: callable() is not just faster, it's also "more correct": hasattr(obj, "__call__") doesn't call base classes. See callable() of the six module: def callable(obj): return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) -- nosy: +hayp

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread Florent Xicluna
Florent Xicluna added the comment: Updated with a special note for "packaging". -- Added file: http://bugs.python.org/file23511/issue13258_callable_v2.diff ___ Python tracker __

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: For packaging I'm not sure it's worth complicating backporting. -- nosy: +eric.araujo, pitrou ___ Python tracker ___ __

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread Florent Xicluna
Florent Xicluna added the comment: Proposed patch. -- keywords: +patch Added file: http://bugs.python.org/file23510/issue13258_callable.diff ___ Python tracker ___ _

[issue13258] replace hasattr(obj, '__call__') with callable(obj)

2011-10-24 Thread Florent Xicluna
New submission from Florent Xicluna : Now that callable() is back in 3.2, we may replace hasattr(obj, '__call__') with callable(obj). The built-in function is easier to read and gives better performance than attribute lookup. $ ./python -m timeit "hasattr(None, '__call__')" 10 loops, bes