[Python-ideas] Descouraging the implicit string concatenation
Robert Vanden Eynde
robertve92 at gmail.com
Wed Mar 14 13:13:17 EDT 2018
Le mer. 14 mars 2018 à 18:04, Carl Meyer <carl at oddbird.net> a écrit :
> On 3/14/18 8:03 AM, Guido van Rossum wrote:
> > I use the feature regularly for long error messages, and when combined
> > with .format() or % it's not so easy to replace it with a + (it would
> > require adding parentheses).
> >
> > So I am against formally discouraging it or adding something to PEP 8.
> >
> > However linters could warn about lists of comma-separated strings with a
> > missing comma.
>
> +1 to all of this.
>
> It's possible to write a linter rule that will reliably catch the
> potential missing-comma errors, while still allowing implicit string
> concatenation where it's useful and readable. The rule is that implicit
> string concatenation should only be disallowed if there are any commas
> present at the same "parenthesization level". Thus, this is allowed:
>
> raise SomeException(
> "This is a really long exception message "
> "which I've split over two lines."
> )
>
> While both of these are disallowed:
>
> fruits = [
> 'orange',
> 'grape'
> 'banana',
> ]
>
> some_str.replace(
> "This is a long string "
> "split over two lines.",
> "And this is another string."
> )
>
>
+1... if this is indeed implemented in a linter !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180314/48c3c05d/attachment.html>
More information about the Python-ideas
mailing list