On Wed, Oct 8, 2014 at 3:30 PM, Chris Angelico <ros...@gmail.com> wrote:

> >
> >
> > That doesn't always seem to have been the case, however.
> > In Python 2.7 and 3.3, I get
> >
> >>>> operator.add is operator.__add__
> > False
>
> Huh. So it is.
>
> rosuav@sikorsky:~$ python3
> Python 3.5.0a0 (default:301b9a58021c, Oct  2 2014, 09:20:24)
> [GCC 4.7.2] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import operator
> >>> operator.add, operator.__add__
> (<built-in function add>, <built-in function add>)
> >>>
> rosuav@sikorsky:~$ python
> Python 2.7.3 (default, Mar 13 2014, 11:03:55)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import operator
> >>> operator.add, operator.__add__
> (<built-in function add>, <built-in function __add__>)
> >>>
>
> Presumably they have the same code behind them, just different
> function names. But anyway, the fact that it doesn't throw back an
> AttributeError proves that both functions do at least exist.
>
> Learn something new every day!


I only tried it in Python 3.4, and I got true. Perhaps it was optimized
slightly after 3.3?

Chris
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to