[Python-3000] callable()

Andrew Koenig ark-mlist at att.net
Fri Jul 28 16:20:13 CEST 2006


> Guido van Rossum wrote:
> > So how about we change callable() and add hashable(), iterable() and
> > whatever else makes sense so that these all become like this:
> >
> >   def callable(x):
> >     return getattr(x, "__call__", None) is not None

> This *still* doesn't fully solve the problem in the case
> of __hash__, since a container may be unhashable due to
> its contents, even if it has a __hash__ method itself.

Methinks that the suggestion includes defining hashable(x) in such a way as
to give the right answer, irrespective of how x.__hash__ is defined.




More information about the Python-3000 mailing list