Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78859
| 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 | 2014-10-08 15:40 -0700 |
| Subject | Re: operator module functions |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14696.1412808045.18130.python-list@python.org> (permalink) |
[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
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