I got bit by this quite recently, leaving out a comma in a long list of strings and I only found the bug by accident.<div><br><div><div>This being python "ideas" I'll throw one out.</div><div><br></div><div>Add another prefix character to strings:</div>

<div><br></div><div><font face="courier new, monospace">    a = [m'abc'</font></div><div><font face="courier new, monospace">         'def']   # equivalent to ['abcdef']</font></div><div><font face="courier new, monospace"><br>

</font></div><div><font face="arial, helvetica, sans-serif">A string with an m prefix is continued on one or more following lines. A string must have an m prefix to be continued (but this change would have to be phased in). A conversion tool need merely recognize the string continuations and insert m's. </font><span style="font-family:arial,helvetica,sans-serif">I chose the m character for multi-line but the character choice is available for bikeshedding. The m prefix can be combined with u and/or r but not with triple-quotes. The following are not allowed:</span></div>

<div><div><br></div><div><div><font face="courier new, monospace">    b = ['abc'    </font><span style="font-family:'courier new',monospace"># syntax error (m is required for continuation)</span></div><div>

<font face="courier new, monospace">         'def')</font></div><div><br></div><div><div><font face="courier new, monospace">    c = [m'abc']</font><span style="font-family:'courier new',monospace">  # syntax error (when m is used, continuation lines must be present)</span></div>

<div><span style="font-family:'courier new',monospace"><br></span></div><div><span style="font-family:'courier new',monospace">    d = [m'abc'</span></div><div><span style="font-family:'courier new',monospace">         m'def']  # syntax error (m only allowed for first string)</span></div>

<div><br></div></div><div><font face="arial, helvetica, sans-serif">The reason to prohibit cases c and d guard against comma errors with these forms. Consider these cases with missing or extra commas.</font></div><div><font face="arial, helvetica, sans-serif"><br>

</font></div><div><font face="courier new, monospace">    e = [m'abc',</font><span style="font-family:'courier new',monospace"> </span><span style="font-family:'courier new',monospace"> # extra comma causes syntax error</span></div>

<div><font face="courier new, monospace">         'def']</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">    f = [m'abc' </font><span style="font-family:'courier new',monospace"> </span><span style="font-family:'courier new',monospace"> # missing comma causes syntax error</span></div>

<div><font face="courier new, monospace">         m'def',</font></div><div><font face="courier new, monospace">         'ghi']</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div>

<font face="arial, helvetica, sans-serif">Yes, I know this doesn't guard against all comma errors. You could protect against more with prefix and suffix (e.g., an m at the end of the last string) but I'm skeptical it's worth it.</font></div>

<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"> Conversion to this could be done in three stages:</font></div><div><font face="arial, helvetica, sans-serif"><br>

</font></div></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><div><font face="arial, helvetica, sans-serif">(1) accept m's (case a), deprecate missing m's (case b), error for misused m's (case c-f)</font></div>

</div></div></div><div><div><font face="arial, helvetica, sans-serif">(2) warn on missing m's (case b)</font></div></div><div><div><font face="arial, helvetica, sans-serif">(3) error on missing m's (case b)</font></div>

</div></blockquote><div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">--- Bruce</font><div><span style="font-family:arial,helvetica,sans-serif">Latest blog post: Alice's Puzzle Page </span><a href="http://www.vroospeak.com/" style="font-family:arial,helvetica,sans-serif" target="_blank">http://www.vroospeak.com</a></div>

<div><div><font face="arial, helvetica, sans-serif">Learn how hackers think: <a href="http://j.mp/gruyere-security" target="_blank">http://j.mp/gruyere-security</a></font></div></div></div>
<br></div></div>