[Python-bugs-list] Missing , not picked up by parser (PR#423)

Tim Peters tim_one@email.msn.com
Tue, 1 Aug 2000 19:10:41 -0400


Sorry, but this is a documented feature:  just as in C, adjacent string
literals are concatenated at compile-time.  You bumped up against the Dark
Side of that.  The Bright Side is, e.g.,

    logfile.write("And here I need to write something "
                  "to a log file that spills over a line "
                  "of source code but I want it want to "
                  "appear in the log as one line."
                  "\n")

It can't be made an error, as lots of code relies on it now.

> -----Original Message-----
> From: python-bugs-list-admin@python.org
> [mailto:python-bugs-list-admin@python.org]On Behalf Of chrisw@nipltd.com
> Sent: Tuesday, August 01, 2000 6:46 PM
> To: python-bugs-list@python.org
> Cc: bugs-py@python.org
> Subject: [Python-bugs-list] Missing , not picked up by parser (PR#423)
>
>
> Full_Name: Chris Withers
> Version: 1.5.2
> OS: WinNT/Linux
> Submission from: zuul.nipltd.com (194.193.44.21)
>
>
> I have something equivalent to this in my code:
>
> mylist = ['x','y'
>           'z']
>
> (the real code has much longer contents, hence the line break ;-)
>
> I think this should throw a parse error 'cos there's a missing comma.
>
> What actually happens is it ends up as:
>
> mylist = ['x','yz']
>
> which is _really_ non-intuitive. I spent a good few hours trying
> to find the
> source
> of an exception in the Squishdot product for Zope until I noticed this.
>
> I note that:
> mystring = 'x''y'
> is also legal, which I suspect is the roundabout source of this problem.
>
> Sure that should raise an error and only the following should
> give the result
> that that does:
> mystring = 'x'+'y'
>
> cheers,
>
> Chris
>
>
>
> _______________________________________________
> Python-bugs-list maillist  -  Python-bugs-list@python.org
> http://www.python.org/mailman/listinfo/python-bugs-list