Greg Ewing wrote:
> Nick Coghlan wrote:
>
>> The use case is being able to block the inheritance of special methods
>> that object provides default implementations for (like '__hash__'),
>> such that a hasattr() check (or a check for a type slot being 0) for
>> those special methods will actually fail.
>
> Maybe descriptors could be given a __has__ slot that got
> called by hasattr() if present. Then a descriptor could
> be created that would have this effect, and your
>
>> class Unhashable(object):
>> __hash__ = Undefined
>
> spelling could be used.
I just realised that a __get__ method that unconditionally raised
AttributeError would do the trick in terms of getting hasattr() to give the
right answer.
This wouldn't help C code that checked for whether or not the relevant tp_*
slot was NULL, though.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com