[Python-ideas] Implicit string literal concatenation considered harmful?

Andrew Barnert abarnert at yahoo.com
Thu May 16 08:06:10 CEST 2013


From: Steven D'Aprano <steve at pearwood.info>

To: python-ideas at python.org


>>  Implicit concatenation is bad because you often use it accidentally when 
> you intended a comma.
> 
> For some definition of "often".

Well, yes. But Guido says he makes this mistake often, and others agree with him, and the whole discussion wouldn't have come up if it weren't a problem. So, we're still left with the conclusion:

>>  There's no way a compiler or linter could help, because there's no 

> programmatic way to distinguish good from bad uses:
> 
> Of course they can *help*. Linters can flag the use of implicit concatenation, 
> and leave it up to the user to decide. That's helping.


You're right; let e rephrase. There's no way a compiler could help, and a linter can mitigate but not solve the problem. Which means the conclusion is actually:

> Assuming all of those givens are true, it seems inescapable that either we need some new syntax, or we have to just accept the problem…

… (with some help from linters).

I should also clarify that "accept the problem" could either mean "ban implicit concatenation" (as Guido initially suggested) or "leave implicit concatenation alone", so it's really 3 choices, not 2.

Does that sound fair now?



More information about the Python-ideas mailing list