id() and is operator

LJ luisjosenovoa at gmail.com
Sun Feb 22 12:53:33 EST 2015


Hi everyone. Quick question here. Lets suppose if have the following numpy array:

b=np.array([[0]*2]*3)

and then:

>>> id(b[0])
45855552
>>> id(b[1])
45857512
>>> id(b[2])
45855552

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


Any clarification is much appreciated.

Cheers,



More information about the Python-list mailing list