So what's happening here?
Larry Martell
larry.martell at gmail.com
Fri Jun 5 08:55:09 EDT 2015
On Fri, Jun 5, 2015 at 8:46 AM, Paul Appleby <pap at nowhere.invalid> wrote:
> I saw somewhere on the net that you can copy a list with slicing. So
> what's happening when I try it with a numpy array?
>
>>>> a = numpy.array([1,2,3])
>>>> b = a[:]
>>>> a is b
> False
>>>> b[1] = 9
>>>> a
> array([1, 9, 3])
is is identity testing, == is equality testing
>>> a = numpy.array([1,2,3])
>>> b = a[:]
>>> a == b
array([ True, True, True], dtype=bool)
>>> id(a)
4510409872
>>> id(b)
4510410192
More information about the Python-list
mailing list