
I have some php experiment. Using dot for string concatenation cause readability hazard. func("foo", "bar". "bazz", "spam". "egg") On Thu, May 16, 2013 at 10:40 PM, MRAB <python@mrabarnett.plus.com> wrote:
On 16/05/2013 08:08, Serhiy Storchaka wrote:
10.05.13 21:48, Guido van Rossum написав(ла):
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.)
As was said before the '+' operator has less priority than the '%' operator and an attribute access, i.e. it requires parenthesis in some cases. However parenthesis introduce a noise and can cause other types of errors.
[snip] I wonder whether we could use ".". Or would that be too confusing?
In all cases only multiline implicit string literal concatenation cause
problem. What if forbid implicit string literal concatenation only between string literals on different physical lines? A deliberate string literal concatenation can be made with explicit line joining.
raise ValueError('Type names and field names must be valid '\ 'identifiers: %r' % name)
raise ValueError('Type names and field names must be valid ' .
'identifiers: %r' % name)
raise ValueError('{} not bottom-level directory in '\ '{!r}'.format(_PYCACHE, path))
raise ValueError('{} not bottom-level directory in ' .
'{!r}'.format(_PYCACHE, path))
______________________________**_________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
-- INADA Naoki <songofacandy@gmail.com>