<div dir="ltr">Setting it to None in the subclass is the intended pattern. But CPython must explicitly handle that somewhere so I don't know how general it is supported. Try defining a list subclass with __len__ set to None and see what happens. Then try the same with MutableSequence.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 7, 2016 at 10:37 AM, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For binary methods, such as __add__, either do not implement or return NotImplemented if the other operand/class is not supported.<br>
<br>
For non-binary methods, simply do not define.<br>
<br>
Except for subclasses when the super-class defines __hash__ and the subclass is not hashable -- then set __hash__ to None.<br>
<br>
Question:<br>
<br>
Are there any other methods that should be set to None to tell the run-time that the method is not supported?  Or is this a general mechanism for subclasses to declare any method is unsupported?<br>
<br>
--<br>
~Ethan~<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>