<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 8, 2014 at 3:30 PM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">><br>
><br>
> That doesn't always seem to have been the case, however.<br>
> In Python 2.7 and 3.3, I get<br>
><br>
>>>> operator.add is operator.__add__<br>
> False<br>
<br>
</span>Huh. So it is.<br>
<br>
rosuav@sikorsky:~$ python3<br>
Python 3.5.0a0 (default:301b9a58021c, Oct  2 2014, 09:20:24)<br>
[GCC 4.7.2] on linux<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import operator<br>
>>> operator.add, operator.__add__<br>
(<built-in function add>, <built-in function add>)<br>
>>><br>
rosuav@sikorsky:~$ python<br>
Python 2.7.3 (default, Mar 13 2014, 11:03:55)<br>
[GCC 4.7.2] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import operator<br>
>>> operator.add, operator.__add__<br>
(<built-in function add>, <built-in function __add__>)<br>
>>><br>
<br>
Presumably they have the same code behind them, just different<br>
function names. But anyway, the fact that it doesn't throw back an<br>
AttributeError proves that both functions do at least exist.<br>
<br>
Learn something new every day!</blockquote></div><br>I only tried it in Python 3.4, and I got true. Perhaps it was optimized slightly after 3.3?<br><br clear="all"><div>Chris</div>
</div></div>