[Python-ideas] Implicit string literal concatenation considered harmful?
Andrew Barnert
abarnert at yahoo.com
Thu May 16 22:55:34 CEST 2013
From: Joao S. O. Bueno <jsbueno at python.org.br>
Sent: Thursday, May 16, 2013 12:03 PM
> On 16 May 2013 12:57, Andrew Barnert <abarnert at yahoo.com> wrote:
>> And this means the parser has to figure out whether you mean dot for
> attribute access or dot for concatenation. That's not exactly a _hard_
> problem, but it's not _trivial_.
>
> If you say it mis not hard for the parser, ok - but it seems
> impossible for humans:
>
> upper = " World"
> print ("Hello". upper)
Given a rule like "it's only concatenation if both arguments are string literals", a sufficiently complex parser, or a sufficiently knowledgeable human, can figure out that this is attribute access. So it's clearly not impossible.
But it's also not trivial. And that's my point. It makes the code harder to read for both parsers and humans, which is a significant tradeoff. If the benefit is high enough, it might be worth it anyway, but I don't know that it is.
More information about the Python-ideas
mailing list