classification
Title: Implicit String Literal Concatenation Is Evil
Type: behavior Stage: resolved
Components: Versions: Python 3.6, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: aklish, r.david.murray
Priority: normal Keywords:

Created on 2014-10-28 18:04 by aklish, last changed 2014-10-28 18:12 by r.david.murray. This issue is now closed.

Messages (3)
msg230163 - (view) Author: Aaron Klish (aklish) Date: 2014-10-28 18:04
Implicit string literal concatenation where
"string1" "string2"
becomes
"string1string2"
should be a language syntax error - not a feature.

This creates a silent error whenever someone builds a list of strings and forgets a comma.

I can't think of any good reason why the language supports this.  There are easier ways to build multi-line strings and there are already two explicit ways to do this on a single line.

It also violates the python principle:
"There should be one— and preferably only one —obvious way to do it"

I realize changing this might break someone's code.  If that is a large concern, maybe the interpreter could support an option to enable/disable support for this.
msg230164 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-28 18:08
This is a long established language feature and is not going to change.  You could talk to one of the python linter projects about adding a lint option for detecting such; that would be the appropriate place for an option that would enable such checking.
msg230165 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-28 18:12
Also, if you really want to pursue it as a language level discussion the appropriate forum would be python-ideas.  You might want to ask on python-list first about how it is used in practice, though, since it is used quite a bit (mostly in multiline expressions...so there might be an argument for doing something about non-multiline concatenation...that's the angle I'd take if you go to python-ideas with it).
History
Date User Action Args
2014-10-28 18:12:02r.david.murraysetmessages: + msg230165
2014-10-28 18:08:55r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg230164

resolution: not a bug
stage: resolved
2014-10-28 18:04:40aklishcreate