osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About the implementation of del in Python 3


Le 06/07/2017 ? 20:56, Nathan Ernst a ?crit :
> In Python, "==" is not a reference equality operator (and I hate Java for
> their misuse of the operator), so I absolutely disagree with using the Java
> description to describe Python's "==" operator, primarily because, well,
> it's wrong. Simple example:
>
> With Python 3.5.2 (should hold for any version 2.4 or greater):
>>>> a = 1
>>>> b = 1
>>>> a == b
> True
>>>> a is b
> True
>>>> c = 1000
>>>> d = 1000
>>>> c == d
> True
>>>> c is d
> False

Strange behavior in Python 3.6.0
 >>> i = 3000
 >>> j = 3000
 >>> i is j
False
 >>> n = 4000 ; m = 4000 ; n is m
True

       dan