[Python-3000] callable()
Guido van Rossum
guido at python.org
Wed Jul 26 18:52:28 CEST 2006
On 7/26/06, Andrew Koenig <ark-mlist at att.net> wrote:
> In other words, the current notion appears to be:
>
> An object is callable iff it has a __call__ attribute.
>
> An object is hashable iff its __hash__ attribute is not None.
>
> This example only strengthens my original intuition that if it is desirable
> to check whether an object has a given property, the way of doing so should
> be uniform across different properties. In other words, if the notion of
> checking for a property is useful, there should be a single abstraction for
> doing that check.
I'd be happy to extend the convention to all such attributes --
setting it to None to mean that the subclass doesn't want to provide
it. That's clean, can't possibly be interpreted to mean anything else,
and doesn't require you to actually call the attribute.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list