f-string anomaly

Lele Gaifax lele at metapensiero.it
Mon May 14 15:24:23 EDT 2018


Ken Kundert <theNurd at nurdletech.com> writes:

> Lele,
>     I'm afraid I was unclear. The ... in the code snippet was intended
> to imply that these lines were appended to the end of the original code,
> where d was defined.

Ok, but then I get a different behaviour:

    Python 3.6.5 (default, May 11 2018, 13:30:17) 
    [GCC 7.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> k=1
    >>> v=2
    >>> d=3
    >>> print(f'Email: {d:{{k}} {{v}}}')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: Invalid format specifier

Which Python version are you using?

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list