Funny behavior of IDLE 3.7.0

Pieter van Oostrum pieter-l at vanoostrum.org
Tue Nov 12 07:39:21 EST 2019


ram at zedat.fu-berlin.de (Stefan Ram) writes:

>   When I enter 
>
> i = 4
> x = 2.3
> s = 'abc'
> print( f'{i=}' )
>
>   into a file window of IDLE 3.7.0, it marks the '=' 
>   sign in the /first/ line and says 'invalid syntax'.
>
>   Remove the »f«, and the error will disappear.

I did this in IDLE 3.7.5, and it gives a syntax error on the last line.
This is correct, because the f-string is in error. Between the curly
braces there should be an expression, possibly followed by a conversion
(!...) and/or a format specification (:...). {i=} is not a correct
expression. When you remove the »f«, it becomes a normal string, where
the {} don't have a special meaning.

-- 
Pieter van Oostrum <piet-l at vanoostrum.org>
WWW: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]


More information about the Python-list mailing list