‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, November 12, 2019 12:39 PM, Pieter van Oostrum 
<piete...@vanoostrum.org> wrote:

> r...@zedat.fu-berlin.de">--protonsignature--...@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.

What the OP was trying to do is valid in python 3.8 (see 
https://docs.python.org/3/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging)
 but not in older versions. To achieve the same result in python 3.7, you have 
to do something like

print(f'i={i}')

--
Heinrich Kruger


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to