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


Groups > comp.lang.python > #79754

Re: id == vs is

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'mrab': 0.05; 'expressions': 0.07; 'builtin': 0.09; 'dan': 0.09; 'python': 0.11; 'question.': 0.14; 'thread': 0.14; '"is"': 0.16; '"x"': 0.16; '>>on': 0.16; '>on': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'rebound': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'weird.': 0.16; ':-)': 0.16; 'all.': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header:User- Agent:1': 0.23; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'change,': 0.30; '>>>>': 0.31; 'yes.': 0.31; 'basic': 0.35; 'created': 0.35; 'something': 0.35; 'test': 0.35; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'level': 0.37; 'clear': 0.37; 'problems': 0.38; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'short': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'expression': 0.60; 'course': 0.61; 'content-disposition:inline': 0.62; 'face': 0.64; 'more': 0.64; 'direct': 0.67; 'nobody': 0.68; 'subject': 0.69; 'apart': 0.72; 'ethan': 0.84; 'furman': 0.84; 'is!': 0.84; 'wandered': 0.84; 'albert': 0.91
Date Mon, 27 Oct 2014 13:36:11 +1100
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: id == vs is
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <544D94B5.80502@mrabarnett.plus.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <544D94B5.80502@mrabarnett.plus.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=fvDlOjIf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=r5UFkecV8NkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=EBOSESyhAAAA:8 a=wX2AXuMGLIgw0ONu5REA:9 a=CjuIK1q_8ugA:10
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.15221.1414379336.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1414379336 news.xs4all.nl 2887 [2001:888:2000:d::a6]:49736
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79754

Show key headers only | View raw


On 27Oct2014 00:41, MRAB <python@mrabarnett.plus.com> wrote:
>On 2014-10-27 00:24, Ethan Furman wrote:
>>On 10/26/2014 05:23 PM, Ethan Furman wrote:
>>>On 10/26/2014 05:12 PM, Dan Stromberg wrote:
>>>>Are the following two expressions the same?
>>>>
>>>>x is y
>>>>
>>>>Id(x) == id(y)
>>>>
>>>>?
>>
>>Listen to MRAB, ignore me.
>>That is all.
>>
>Well, apart of Joshua's qualifications, that is! :-)

Let's make it clear for the OP, since this thread seems to have wandered into 
the realms of the confusing, for what is a basic question.

The short answer is "yes".

The longer answer is:

   if nobody else is fiddling with "x" and "y"
   and if id() is the normal builtin python "id" function

Then yes.

The "is" test is more direct and less subject to iffiness because the longer 
expression using id() leaves more scope/time for things to change, and of 
course "id" itself can be rebound to something weird.

Cheers,
Cameron Simpson <cs@zip.com.au>

The significant problems we face cannot be solved at the same level of
thinking we were at when we created them.       - Albert Einstein

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


Thread

Re: id == vs is Cameron Simpson <cs@zip.com.au> - 2014-10-27 13:36 +1100
  Re: id == vs is Roy Smith <roy@panix.com> - 2014-10-27 09:17 -0400

csiph-web