Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79754 > unrolled thread
| Started by | Cameron Simpson <cs@zip.com.au> |
|---|---|
| First post | 2014-10-27 13:36 +1100 |
| Last post | 2014-10-27 09:17 -0400 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2014-10-27 13:36 +1100 |
| Subject | Re: id == vs is |
| Message-ID | <mailman.15221.1414379336.18130.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-10-27 09:17 -0400 |
| Message-ID | <roy-53C705.09170427102014@news.panix.com> |
| In reply to | #79754 |
In article <mailman.15221.1414379336.18130.python-list@python.org>, Cameron Simpson <cs@zip.com.au> wrote: > 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. Not to mention that Python is case-sensitive and in the code as presented by the OP: >>>>Id(x) == id(y) those are two different functions :-)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web