[Stephen J. Turnbull]
> Is this syntax useful? Or is it just a variant of purity trying to
> escape Pandora's virtualbox? I mean, am I going to see it often
> enough to get used to it? Or am I going to WTF at it for the rest of
> my life?
>
I don't know about the line breaks, but in recent weeks I've found myself
more than once having to remind myself that inside interpolations, you must
use the other type of quote. Things like
print(f"{source.removesuffix(".py")}.c: $(srcdir)/{source}")
Learning that inside {} you can write any expression is easy (it's a real
Aha! moment -- that's the power of f-strings). Remembering that you have to
switch up the quote characters there is hard -- it doesn't occur very
often, and the reason is obscure. By the time my mental parser has made it
to the argument list of removesuffix() it has already forgotten that it's
inside an f-string and my fingers just reach for my favorite quote
character.
And the error isn't really helping either:
```
>>> print(f"{source.removesuffix(".py")}.c: $(srcdir)/{source}")
File "<stdin>", line 1
print(f"{source.removesuffix(".py")}.c: $(srcdir)/{source}")
^
SyntaxError: f-string: unmatched '('
```
--
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/IWXRQFTNWMOW6ZLBOQW3U4KE2TDKXNWO/
Code of Conduct: http://python.org/psf/codeofconduct/