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

Haoyi Li haoyi.sg at gmail.com
Thu May 16 05:50:51 CEST 2013


To be fair, I've made this mistake twice in the last week. It's trivially
fixed once you find it, but a missing , is pretty small and hard to miss!
It caused a fair amount of head scratching

I don't believe in the "kick it to the linter" solution, since that's
basically a non-solution (don't know if it should be good or bad, so let
someone else decide!). Until we get some @I_Know_What_Im_Doing decorator so
that, in the source code, we can tell the linter to ignore things, it's
just going to pop up every time and get in peoples way and add to the
lint-spam that accompanies most major projects.

Somewhat unrelated, but have any linter managed to solve this issue,
whether storing a fine-grained stuff-to-be-ignored list in in-code pragmas
or in a separate .linter_ignored file that somehow works while line numbers
are constantly changing and such?


On Wed, May 15, 2013 at 11:24 PM, Steven D'Aprano <steve at pearwood.info>wrote:

> On 16/05/13 12:54, Andrew Barnert wrote:
>
>  Summarizing (more in hopes that someone will correct me if I've missed
>> something important than to help you or anyone else...):
>>
>> Implicit concatenation is bad because you often use it accidentally when
>> you intended a comma.
>>
>
> For some definition of "often".
>
> If I've ever made this error, it was so long ago, and so trivially fixed,
> that I don't remember it.
>
>
>  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.
>
> If you're like me, and use implicit concatenation frequently with few or
> no problems, then you'll configure the linter to skip the warning. If
> you're one of the people who rarely or never uses it deliberately, or you
> work for Google where it goes against their in-house style guide, then
> you'll tell the linter to treat it as an error.
>
>
> I think that this is the sort of issue that linters are designed to solve.
>
>
>
> --
> Steven
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130515/5e7fbc69/attachment.html>


More information about the Python-ideas mailing list