On 14 October 2012 20:57, Mike Meyer <span dir="ltr"><<a href="mailto:mwm@mired.org" target="_blank">mwm@mired.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5">On Sun, 14 Oct 2012 07:40:57 +0200<br>
Yuval Greenfield <<a href="mailto:ubershmekel@gmail.com">ubershmekel@gmail.com</a>> wrote:<br>
<br>
> On Sun, Oct 14, 2012 at 2:04 AM, MRAB <<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>> wrote:<br>
><br>
> > If it's more than one codepoint, we could prefix with the length of the<br>
> > codepoint's name:<br>
> ><br>
> > def __12CIRCLED_PLUS__(x, y):<br>
> >     ...<br>
> ><br>
> ><br>
> That's a bit impractical, and why reinvent the wheel? I'd much rather:<br>
><br>
> def \u2295(x, y):<br>
>     ....<br>
><br>
> So readable I want to read it twice. And that's not legal python today so<br>
> we don't break backwards compatibility!<br>
<br>
</div></div>Yes, but we're defining an operator for instances of the class, so it<br>
needs the 'special' method marking:<br>
<br>
def __\u2295__(self, other):<br>
<br>
Now *that's* pretty!<br>
<div class="im HOEnZb"><br>
    <mike</div></blockquote><div><br></div><div>I much preferred your first choice:</div><div>def __$⊕__(self, other):</div><div><br></div><div>But to keep the "$" unused we can write:</div><div>def __op_⊕__(self, other):</div>

<div>(new methods will take precedence over the older __add__ and so forth)</div><div><br></div><div>What we can do then is use the "\u" syntax to let people without unicode editors have accessibility:</div><div>

def __op_\u2295__(self, other):</div><div>...later in the code...</div><div>new = first \u2295 second</div><div><br></div><div>Which adds consistency whereas before we could only use that in specific circumstances (inside strings), reducing cognitive burden.</div>

</div>