overriding not operator in Python
<p>I cannot find the method corresponding to <code>not x</code> operator. There is one for <code>and,or,xor</code> tho. Where is it?
<a href="https://docs.python.org/3/reference/datamodel.html" rel="nofollow">https://docs.python.org/3/reference/datamodel.html</a></p>

<blockquote>
  <p>There is one for <code>and,or,xor</code> tho</p>
</blockquote>

<p>The methods you're looking at are for <em>bitwise</em> <code>&amp;</code>, <code>|</code>, and <code>^</code>, not <code>and</code>, <code>or</code>, or <code>xor</code> (which isn't even a Python operator).</p>

<p><code>not</code> cannot be overloaded, just like <code>and</code> and <code>or</code> can't be overloaded. Bitwise <code>~</code> can be overloaded, though; that's <code>__invert__</code>.</p>

<p>If you're in a situation where you wish you could overload <code>not</code>, you'll either have to make do with overloading <code>~</code> instead, or you'll have to write your own <code>logical_not</code> function and use that instead of the <code>not</code> operator.</p>

python operator-overloading operators