Am 15.02.14 01:57, schrieb Chris Angelico:
Can you give an example of an ambiguous case? Fundamentally, the 'is'
operator tells you whether its two operands are exactly the same
object, nothing more and nothing less, so I assume your "ambiguous
cases" are ones where it's possible for two things to be either the
same object or two indistinguishable ones.
What about the thing I posted down in this thread?
>>> import numpy as np
>>> a=np.array([1, 2, 3, 4])
>>> b=a[:]
>>> id(a)
140267900969344
>>> id(b)
140267901045920
So, a and b are different things, right?
>>> b[1]=37
>>> b
array([ 1, 37, 3, 4])
>>> a
array([ 1, 37, 3, 4])
Still they are connected. I can imagin that id() is just a debugging
tool for extensions. What useful applications does it have outside of this?
Christian
--
https://mail.python.org/mailman/listinfo/python-list