I originally thought this was dangerous, and then changed my mind, and find this very useful when wrapping long strings to fit in 80 columns.
On May 10, 2013 7:51 PM, "Nick Coghlan" <ncoghlan@gmail.com> wrote:
>
>
> On 11 May 2013 04:50, "Guido van Rossum" <guido@python.org> wrote:
> >
> > I just spent a few minutes staring at a bug caused by a missing comma
> > -- I got a mysterious argument count error because instead of foo('a',
> > 'b') I had written foo('a' 'b').
> >
> > This is a fairly common mistake, and IIRC at Google we even had a lint
> > rule against this (there was also a Python dialect used for some
> > specific purpose where this was explicitly forbidden).
> >
> > Now, with modern compiler technology, we can (and in fact do) evaluate
> > compile-time string literal concatenation with the '+' operator, so
> > there's really no reason to support 'a' 'b' any more. (The reason was
> > always rather flimsy; I copied it from C but the reason why it's
> > needed there doesn't really apply to Python, as it is mostly useful
> > inside macros.)
> >
> > Would it be reasonable to start deprecating this and eventually remove
> > it from the language?
>
> I could live with it if we get "dedent()" as a string method. I'd be even happier if constant folding was extended to platform independent method calls on literals, but I don't believe there's a sane way to maintain the "platform independent" constraint.
>
> OTOH, it's almost on the scale of "remove string mod formatting". Shipping at least a basic linting tool in the stdlib would probably be almost as effective and substantially less disruptive. lib2to3 should provide some decent infrastructure for that.I have cc'd the code-quality mailing list since several linger authors are subscribed there.
_______________________________________________ code-quality mailing list code-quality@python.org http://mail.python.org/mailman/listinfo/code-quality
cursor.execute('SELECT foo, bar FROM mytable '
'WHERE baz = %(baz)s',
{'baz': baz})If you have a check for the number of mandatory arguments of a callable, you will catch some of the issues caused by this (not all of them though...)