Re: id() and is operator

2015-02-22 Thread Marko Rauhamaa
Terry Reedy : > On 2/22/2015 4:25 PM, Marko Rauhamaa wrote: >> This is a true statement: >> >> If X is Y, then id(X) == id(Y). >> >> However, this is generally not a true statement: >> >> If X is Y, then id(X) is id(Y). > > If X and Y exist at the *same time*, then (X is Y) == (id(X) is id

Re: id() and is operator

2015-02-22 Thread Gary Herron
On 02/22/2015 10:02 PM, Terry Reedy wrote: On 2/22/2015 4:25 PM, Marko Rauhamaa wrote: LJ : id(b[0]) 4582 [...] id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same object. Now, b[0] is b[2] False This is a true statement: If

Re: id() and is operator

2015-02-22 Thread Terry Reedy
On 2/22/2015 12:53 PM, LJ wrote: Hi everyone. Quick question here. Lets suppose if have the following numpy array: b=np.array([[0]*2]*3) and then: id(b[0]) 4582 id(b[1]) 45857512 id(b[2]) 4582 Please correct me if I am wrong, You are, as other explained > but according to th

Re: id() and is operator

2015-02-22 Thread Terry Reedy
On 2/22/2015 4:25 PM, Marko Rauhamaa wrote: LJ : id(b[0]) 4582 [...] id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same object. Now, b[0] is b[2] False This is a true statement: If X is Y, then id(X) == id(Y). However, this

Re: id() and is operator

2015-02-22 Thread Steven D'Aprano
LJ wrote: > Hi everyone. Quick question here. Lets suppose if have the following numpy > array: > > b=np.array([[0]*2]*3) > > and then: > id(b[0]) > 4582 id(b[1]) > 45857512 id(b[2]) > 4582 > > Please correct me if I am wrong, but according to this b[2] and b[0] are > th

Re: id() and is operator

2015-02-22 Thread Chris Angelico
On Mon, Feb 23, 2015 at 8:25 AM, Marko Rauhamaa wrote: > This is a true statement: > >If X is Y, then id(X) == id(Y). > > However, this is generally not a true statement: > >If X is Y, then id(X) is id(Y). Irrelevant, because the identities of equal integers didn't come into this. ChrisA

Re: id() and is operator

2015-02-22 Thread Marko Rauhamaa
LJ : id(b[0]) > 4582 [...] id(b[2]) > 4582 > > Please correct me if I am wrong, but according to this b[2] and b[0] > are the same object. Now, > b[0] is b[2] > False This is a true statement: If X is Y, then id(X) == id(Y). However, this is generally not a true statem

Re: id() and is operator

2015-02-22 Thread Laura Creighton
Ooops, I missed the numpy, so I thought that it was the contents of the array that was causing the problem. My very bad. Apologies. Laura -- https://mail.python.org/mailman/listinfo/python-list

Re: id() and is operator

2015-02-22 Thread Gary Herron
On 02/22/2015 09:53 AM, LJ wrote: Hi everyone. Quick question here. Lets suppose if have the following numpy array: b=np.array([[0]*2]*3) and then: id(b[0]) 4582 id(b[1]) 45857512 id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same o

Re: id() and is operator

2015-02-22 Thread Chris Angelico
On Mon, Feb 23, 2015 at 5:13 AM, Laura Creighton wrote: > In a message of Sun, 22 Feb 2015 09:53:33 -0800, LJ writes: >>Hi everyone. Quick question here. Lets suppose if have the following numpy >>array: >> >>b=np.array([[0]*2]*3) >> >>and then: >> > id(b[0]) >>4582 > id(b[1]) >>45857

Re: id() and is operator

2015-02-22 Thread Laura Creighton
In a message of Sun, 22 Feb 2015 09:53:33 -0800, LJ writes: >Hi everyone. Quick question here. Lets suppose if have the following numpy >array: > >b=np.array([[0]*2]*3) > >and then: > id(b[0]) >4582 id(b[1]) >45857512 id(b[2]) >4582 > >Please correct me if I am wrong, but ac

id() and is operator

2015-02-22 Thread LJ
Hi everyone. Quick question here. Lets suppose if have the following numpy array: b=np.array([[0]*2]*3) and then: >>> id(b[0]) 4582 >>> id(b[1]) 45857512 >>> id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same object. Now, >>> b[0] is b[2]