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

Greg Ewing greg.ewing at canterbury.ac.nz
Sat May 11 07:39:57 CEST 2013


Andrew Barnert wrote:
> Except that % formatting is supposed to be one of those 
> "we haven't deprecated it, but we will, so stop using it" features,
> so it seems a little odd to add new syntax to make % formatting easier.

Except that the same problem also occurs with .format() formatting.

 >>> "a{}b" "c{}d" .format(1,2)
'a1bc2d'

but

 >>> "a{}b" + "c{}d" .format(1,2)
'a{}bc1d'

so you need

 >>> ("a{}b" + "c{}d") .format(1,2)
'a1bc2d'

> Also, doesn't this imply that ... is now an operator in some contexts,
 > but a literal in others?

It would have different meanings in different contexts, yes.

But I wouldn't think of it as an operator, more as a token
indicating string continuation, in the same way that the
backslash indicates line continuation.

-- 
Greg



More information about the Python-ideas mailing list