This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author milko.krachounov
Recipients georg.brandl, milko.krachounov
Date 2009-09-27.14:23:51
SpamBayes Score 0.0017431452
Marked as misclassified No
Message-id <>
hasattr(x, '__call__') has been suggested as a replacement for
callable(x) in the documentation and in the warning when running
python2.6 with -3. It is also what 2to3 replaces it with. However, the
two are not equivalent.

1. I can add a __call__ attribute to my object with "obj.__call__ =
lambda x:x". That will not make the object callable, callable() on
Python 2.6 returns False, but hasattr(obj, '__call__') returns True.
2. I can implement a __getattr__ that returns something for every
possible attribute name. Again, this doesn't make the object callable,
nor does callable(obj) in Python 2.6 return True.

I think a closer replacement for "callable(x)" would be "'__call__' in
Date User Action Args
2009-09-27 14:23:55milko.krachounovsetrecipients: + milko.krachounov, georg.brandl
2009-09-27 14:23:55milko.krachounovsetmessageid: <>
2009-09-27 14:23:53milko.krachounovlinkissue7006 messages
2009-09-27 14:23:52milko.krachounovcreate