Bug or feature: double strings as one

John Machin sjmachin at lexicon.net
Fri Aug 7 19:46:03 EDT 2009


On Aug 8, 3:43 am, alex23 <wuwe... at gmail.com> wrote:
> kj <no.em... at please.post> wrote:
> > Feature, as others have pointed out, though I fail to see the need
> > for it, given that Python's general syntax for string (as opposed
> > to string literal) concatenation is already so convenient.  I.e.,
> > I fail to see why
>
> > x = ("first part of a very long string "
> >      "second part of a very long string")
>
> > is so much better than
>
> > x = ("first part of a very long string " +
> >      "second part of a very long string")
>
> My impression is it's mostly for one of clarity. It's especially
> useful with regular expressions, as it allows for comments to document
> each element of the regex (following example shamelessly taken from
> the docs (albeit with personal preferences on formatting))):
>
> re.compile(
>     "[A-Za-z_]"       # letter or underscore
>     "[A-Za-z0-9_]*"   # letter, digit or underscore
> )
>
> Not having the plus sign present does assist (IMO) in the ease of
> parsing the regex.
> re.compile(

re.VERBOSE?



More information about the Python-list mailing list