Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78859

Re: operator module functions

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 <ckaynor@zindagigames.com>
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&gt;': 0.22; 'cc:addr:python.org': 0.22; '&gt;&gt;&gt;': 0.24; 'cc:2**0': 0.24; '&gt;': 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 <CAPTjJmqfctz=9dRY2HHOPH5N0Uh6i=F7jkGFbQDnYGe9qn=veA@mail.gmail.com>
References <54349662$0$12987$c3e8da3$5496439d@news.astraweb.com> <facda5ec-ecd9-43d0-99b3-b98f945a9a2d@googlegroups.com> <mailman.14675.1412760741.18130.python-list@python.org> <c9lp4mFl997U1@mid.individual.net> <CAPTjJmqfctz=9dRY2HHOPH5N0Uh6i=F7jkGFbQDnYGe9qn=veA@mail.gmail.com>
From Chris Kaynor <ckaynor@zindagigames.com>
Date Wed, 8 Oct 2014 15:40:18 -0700
Subject Re: operator module functions
To Chris Angelico <rosuav@gmail.com>
Content-Type multipart/alternative; boundary=089e0102ffe843b80d0504f10185
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14696.1412808045.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, 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  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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

operator module functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-08 12:41 +1100
  Re: operator module functions Terry Reedy <tjreedy@udel.edu> - 2014-10-08 02:28 -0400
  Re: operator module functions marco.nawijn@colosso.nl - 2014-10-08 01:46 -0700
    Re: operator module functions Chris Angelico <rosuav@gmail.com> - 2014-10-08 20:32 +1100
      Re: operator module functions Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-10-09 10:37 +1300
        Re: operator module functions Chris Angelico <rosuav@gmail.com> - 2014-10-09 09:30 +1100
        Re: operator module functions Chris Kaynor <ckaynor@zindagigames.com> - 2014-10-08 15:40 -0700
    Re: operator module functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-08 21:57 +1100
      Re: operator module functions Terry Reedy <tjreedy@udel.edu> - 2014-10-08 15:09 -0400
      Re: operator module functions Ethan Furman <ethan@stoneleaf.us> - 2014-10-08 12:38 -0700
      Re: operator module functions random832@fastmail.us - 2014-10-08 15:49 -0400
      Re: operator module functions Gelonida N <gelonida@gmail.com> - 2014-10-08 23:05 +0200
      Re: operator module functions Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-08 15:23 -0600
      Re: operator module functions Ethan Furman <ethan@stoneleaf.us> - 2014-10-08 14:49 -0700
      Re: operator module functions Chris Kaynor <ckaynor@zindagigames.com> - 2014-10-08 14:21 -0700
      Re: operator module functions Ben Finney <ben+python@benfinney.id.au> - 2014-10-09 08:57 +1100
      Re: operator module functions Terry Reedy <tjreedy@udel.edu> - 2014-10-08 18:46 -0400
      Re: operator module functions Ethan Furman <ethan@stoneleaf.us> - 2014-10-08 16:35 -0700
      Re: operator module functions Ned Batchelder <ned@nedbatchelder.com> - 2014-10-08 21:41 -0400

csiph-web