[issue43151] is with literals in 3.8 release

2021-02-06 Thread Gary Litvin


New submission from Gary Litvin :

>>> x = 'a'
>>> x is 'a'
True
>>> if x is 'a':
print(x)

SyntaxError: "is" with a literal. Did you mean "=="?

How come?

--
messages: 386575
nosy: garylitvin
priority: normal
severity: normal
status: open
title: is with literals in 3.8 release
versions: Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue43151>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43151] is with literals in 3.8 release

2021-02-06 Thread Gary Litvin


Gary Litvin  added the comment:

Thank you for your responses. I understand the difference between == 
and "is" and the intentional change in 3.8. My question is about what 
seems to be inconsistent treatment in x is 'a' and if a is 'a': ...

At 12:49 AM 2/7/2021, Raymond Hettinger wrote:

>Raymond Hettinger  added the comment:
>
>As Dennis says, this is an intentional behavior and will help you avoid bugs.
>
>--
>nosy: +rhettinger
>resolution:  -> not a bug
>stage:  -> resolved
>status: open -> closed
>
>___
>Python tracker 
><https://bugs.python.org/issue43151>
>___

--

___
Python tracker 
<https://bugs.python.org/issue43151>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43151] is with literals in 3.8 release

2021-02-07 Thread Gary Litvin


Gary Litvin  added the comment:

I noticed it in IDLE 3.8. I installed 3.8 because it is a fairly 
recent release described as "stable." Thanks to everyone for considering this.

At 03:41 AM 2/7/2021, you wrote:

>Dennis Sweeney  added the comment:
>
>I think the strangeness is happening because sometimes, the warning 
>is printed to stderr, while other times, IDLE's parser notices the 
>"is " anti-pattern and raises a SyntaxError.
>
>See the attached screenshot for the IDLE output versus the console 
>output for a recent 3.10 build.
>
>--
>Added file: https://bugs.python.org/file49796/idle_stderr.jpg
>
>___
>Python tracker 
><https://bugs.python.org/issue43151>
>___

--

___
Python tracker 
<https://bugs.python.org/issue43151>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com