[email protected] (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 <[email protected]>
WWW: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list