Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'operator': 0.03; 'python3': 0.07; 'subject:module': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '2.7': 0.14; '2.7.3': 0.16; '3.3,': 0.16; 'exist.': 0.16; 'throw': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'slightly': 0.19; '>>>': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'chris': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'code': 0.31; '>>>>': 0.31; 'names.': 0.31; 'received:209.85.212': 0.32; 'linux': 0.33; 'received:209.85': 0.35; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'behind': 0.37; 'received:209': 0.37; 'skip:& 10': 0.38; 'fact': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'is.': 0.60; 'new': 0.61; 'back': 0.62; 'more': 0.64; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'mar': 0.68; 'optimized': 0.68; '2014,': 0.84; 'presumably': 0.84; 'proves': 0.84; 'day!': 0.85 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=inbVHaUsjYGBWbhsd5vYLPt4r/yNAbR2X4svHfRxvfM=; b=R+QIHhu3s/L/7DBT27Cb7ar8h1hHuelQyak2IE5XfbH1yt+IyCpxxKJxK3kcfYU+jc 9cYoXLrVVFi25EFGtWyX1QRxf6CZGCP3RPVw7mW9+ZrU2XHZD7Q5OdARvDc9y7SMj+N3 aNTOy4Ri48yyLTAB0/80Vl0gRmdt0a+BjpQFF0v5zWNiz5sHqkBYMhz3TWtwpr0O6Jid CC90S+JQHhdzFbZxhvr4FCKA+bffDjn5/kl1Clv4s89e1EQ9CPMF0sdGgyGX4aHjfswC QfG5mh3oIROagHzMA3PbhndSPh5mTaa/v6AVX4OAwNy1dx7+hC/UPZAV2phkoS0l2tag hcfA== X-Gm-Message-State: ALoCoQndeRdOfa9BQoiapZ3duJgjF6u23hcdBW3WFeBWIikqltkhYpZL3pGCrsOrRusKmQ1Q6XWF X-Received: by 10.194.88.99 with SMTP id bf3mr14159708wjb.16.1412808038383; Wed, 08 Oct 2014 15:40:38 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <54349662$0$12987$c3e8da3$5496439d@news.astraweb.com> From: Chris Kaynor Date: Wed, 8 Oct 2014 15:40:18 -0700 Subject: Re: operator module functions To: Chris Angelico Content-Type: multipart/alternative; boundary=089e0102ffe843b80d0504f10185 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412808045 news.xs4all.nl 2948 [2001:888:2000:d::a6]:45381 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78859 --089e0102ffe843b80d0504f10185 Content-Type: text/plain; charset=UTF-8 On Wed, Oct 8, 2014 at 3:30 PM, Chris Angelico 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__ > (, ) > >>> > 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__ > (, ) > >>> > > 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 --089e0102ffe843b80d0504f10185 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On W= ed, Oct 8, 2014 at 3:30 PM, Chris Angelico <rosuav@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=C2=A0 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 Pyt= hon 3.4, and I got true. Perhaps it was optimized slightly after 3.3?
Chris
--089e0102ffe843b80d0504f10185--