About the implementation of del in Python 3

Nathan Ernst nathan.ernst at gmail.com
Fri Jul 7 10:41:00 EDT 2017


Looks like single expression statements are handled a bit differently than
multiple expression statements:

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> n = 4000; m = 4000; n is m
True
>>> n = 4000
>>> m = 4000
>>> n is m
False
>>>

On Fri, Jul 7, 2017 at 2:29 AM, Dan Wissme <wissme at free.fr> wrote:

> 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
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list