[Python-Dev] String concatenation (original) (raw)

Isaac Morland ijmorlan at cs.uwaterloo.ca
Sat Aug 23 13:57:54 CEST 2008


On Sat, 23 Aug 2008, Fredrik Lundh wrote:

removing it is a bad idea for the reasons already given, but requiring parentheses could help.

that is, the following would result in a warning or an error: L = ["first", "second" "third"] but the following wouldn't: L = ["first", ("second" "third")] T = ("This is a line of text.\n" "This is another line of text.\n")

This would avoid accidentally leaving out commas in list construction, but tuple construction would still have the same problem. And it's still a change in the language which would probably affect lots of existing code. I doubt if there is any problem-free way of trying to address this issue by changing the language.

One suggestion to help minimize problems when writing code would be always to put the optional trailing comma:

[ 'a', 'b', 'c', ]

which is also a revision-control-friendly practice, and in the tuple constuction context avoids the possibility of removing an item from a two-tuple and ending up with not a one-tuple but instead just the item itself.

Isaac Morland CSCF Web Guru DC 2554C, x36650 WWW Software Specialist



More information about the Python-Dev mailing list