[Python-ideas] Descouraging the implicit string concatenation

Serhiy Storchaka storchaka at gmail.com
Wed Mar 14 11:38:49 EDT 2018


14.03.18 14:18, Facundo Batista пише:
> What would you think about formally descouraging the following idiom?
> 
>      long_string = (
>          "some part of the string "
>          "with more words, actually is the same "
>          "string that the compiler puts together")
> 
> We should write the following, instead:
> 
>      long_string = (
>          "some part of the string " +
>          "with more words, actually is the same " +
>          "string that the compiler puts together")
> 
> I know that "no change to Python itself" is needed, but having a
> formal discouragement of the idiom will help in avoiding people to
> fall in mistakes like:
> 
> fruits = {
>      "apple",
>      "orange"
>      "banana",
>      "melon",
> }
> 
> (and even making the static analysers, like pyflakes or pylint, to
> show that as a warning)
> 
> Note that there's no penalty in adding the '+' between the strings,
> those are resolved at compilation time.

This already was discussed 5 years ago. See the topic "Implicit string 
literal concatenation considered harmful?" started by GvR.

https://mail.python.org/pipermail/python-ideas/2013-May/020527.html

First that reviving this discussion please take a look at arguments made 
at former discussion, and make sure that your arguments are new.



More information about the Python-ideas mailing list