[Python-ideas] String interpolation for all literal strings

Jonathan Slenders jonathan at slenders.be
Sat Aug 8 19:23:19 CEST 2015


Why don't we allow any possible expression to be used in the context of a
decorator? E.g. this is not possible.

@a + b
def function():
    pass

While these are:

@a(b + c)
@a.b
@a.b.c
def function():
    pass

I guess there we also had a discussion about whether or not to limit the
grammar, and I guess we had a reason.

I don't like the idea to give the user too much freedom in f-string. A
simple expression like addition, ok. But no comprehension, lambdas, etc...
It's impossible to go back if this turns out badly, but we can always add
more freedom later on.


One more coments after reading the PEP:
- I don't like that double braces are replaced by a single brace. Why not
keep backslash \{  \} for the literals. In the PEP we have '{...}' for
variables. (Instead of '\{...}') So that works fine.

Jonathan





2015-08-08 12:28 GMT+02:00 Sven R. Kunze <srkunze at mail.de>:

> On 07.08.2015 21:17, Yury Selivanov wrote:
>
>> Yes. And overall I think that
>>
>>     sum = a + b
>>     print(f'the sum is {sum}')
>>
>> is more pythonic (readability, explicitness etc) than this:
>>
>>     print(f'the sum is {a + b}')
>>
>>
> I have to admit I like shorter one more. It is equally well readable and
> explicit AND it is shorter.
>
> As long as people do not abuse expressions to a degree of unreadability
> (which should be covered by code reviews when it comes to corporal code), I
> am fine with exposing more possibilities.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150808/1edec7cb/attachment.html>


More information about the Python-ideas mailing list