Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.021 X-Spam-Evidence: '*H*': 0.96; '*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; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'throw': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 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; 'linux': 0.33; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'behind': 0.37; 'fact': 0.38; 'is.': 0.60; 'new': 0.61; 'back': 0.62; 'more': 0.64; 'different': 0.65; 'mar': 0.68; '2014,': 0.84; 'presumably': 0.84; 'proves': 0.84; 'day!': 0.85; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MihlWwXcQjezGZ+Gq3xDntULsrmazn2wnJIhvcVNfeg=; b=rLT/ViUUxHEDWR4H3UxqY2JWqxjvO1FlXGMcPgBopx2IP/xA9PZI6XJzhpGwUORROk Jmx9fJZgh8I21UFXr3C1tBMX3VyszQTOJEFgOFgjAGzA71IgxsqKRwtQo0VI/BmS6Ils S/97RntAeJV2JXDOzIMsqUWUNOmMHDyuufV57P7aBG5er6r6M4PnePnTqPdye+iCtUzH q8rxWs01F2DfBPuV+Nx2ZUlJIPL+N22nkYaXMAAsxVzOjZXuDmlVP3x2xx+Nht16RK+U j9zJ9NhJgQrLzkQ+AMvKfthvGJ/LQNdIJavBKBtn3F2LSEdmJxg/Xkc4N5IOdA+/V6aJ 9jKQ== MIME-Version: 1.0 X-Received: by 10.43.108.212 with SMTP id ed20mr869408icc.12.1412807431103; Wed, 08 Oct 2014 15:30:31 -0700 (PDT) In-Reply-To: References: <54349662$0$12987$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 9 Oct 2014 09:30:31 +1100 Subject: Re: operator module functions From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412807434 news.xs4all.nl 2938 [2001:888:2000:d::a6]:42495 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78858 On Thu, Oct 9, 2014 at 8:37 AM, Gregory Ewing wrote: > Chris Angelico wrote: > >>>>> operator.add is operator.__add__ >> >> True > > > 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! ChrisA