[Python-Dev] PEP 30XZ: Simplified Parsing

Brian Harring ferringb at gmail.com
Wed May 2 20:19:37 CEST 2007


On Wed, May 02, 2007 at 01:53:01PM -0400, A.M. Kuchling wrote:
> On Wed, May 02, 2007 at 04:42:09PM +0100, Michael Foord wrote:
> > Implicit string concatenation is massively useful for creating long 
> > strings in a readable way though:
> 
> This PEP doesn't seem very well-argued: "It's a common mistake to
> leave off a comma, and then scons complains that it can't find
> 'foo.cbar.c'."  Yes, and then you say "oh, right!" and add the missing
> comma; problem fixed!  The whole cycle takes about a minute.  Is this
> really an issue worth fixing?

The 'cycle' can also generally be avoided via a few good habits-

sourceFiles = [
 'foo.c',
 'bar.c',
 #...many lines omitted...
 'q1000x.c']

That's the original example provided; each file is on a seperate line 
so it's a bit easier to tell what changed if you're reviewing the 
delta.  That said, doing

sourceFiles = [
 'foo.c',
 'bar.c',
 #...many lines omitted...
 'q1000x.c',
]

is (in my experience) a fair bit better; you *can* have the trailing 
comma without any ill affects, plus shifting the ']' to a seperate 
line is lessy noisy delta wise for the usual "add another string to 
the end of the list".

Personally, I'm -1 on nuking implicit string concatenation; the 
examples provided for the 'why' aren't that strong in my experience, 
and the forced shift to concattenation is rather annoying when you're 
dealing with code limits (80 char limit for example)-

                        dprint("depends level cycle: %s: "
                               "dropping cycle for %s from %s" % 
                                (cur_frame.atom, datom,
                                 cur_frame.current_pkg),
                                "cycle")

Converting that over isn't hard, but it's a great way to inadvertantly 
bite yourself in the butt- triple quote isn't usually much of an 
option in such a case also since you don't want the newlines coming 
through.

~harring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20070502/d0f7a90c/attachment.pgp 


More information about the Python-Dev mailing list