[Python-3000] callable()

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Fri Jul 28 10:56:01 CEST 2006


Marcin 'Qrczak' Kowalczyk wrote:
> Stefan Behnel <behnel_ml at gkec.informatik.tu-darmstadt.de> writes:
> 
>> It just says: I support the protocol, so it makes sense to apply the
>> protocol operations to me if you need to.
>>
>> I think that's perfectly reasonable semantics for the three functions.
> 
> I see no essential difference between an object which doesn't support
> a protocol at all, and an object for which using the given protocol
> always fails.
> 
> What is hashable() useful for, especially if so loosely defined?

Well, if you /know/ it always fails, you should best disable it by setting it
to None, right?

So, if hashable() returns True, it means that a) the designer didn't care
about switching it off or b) there are cases where it works, so it makes sense
to try calling it.

The first case (i.e. the one you described) is bad design and therefore
ignorable, the second fits the above semantics.

Stefan



More information about the Python-3000 mailing list