[Python-3000] callable()

Guido van Rossum guido at python.org
Fri Jul 28 03:05:18 CEST 2006


On 7/27/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 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.
>
> It might be good enough for whatever these hypothetical
> hashability-testing use cases require though. We'd have
> to catch one of those elusive beasts to find out...

I already proposed to deal with that the same way we handle signature
mismatches with __call__ -- you'll find out when you actually try to
do it. That should be good enough.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list