line continuations with backslash

Paul Rubin phr-n2001 at nightsong.com
Fri Aug 24 22:23:38 EDT 2001


Is there a particular reason in Python why you can't continue a line with
a backslash in the middle of a literal, like in C?

For what I'm doing it would be useful to be able to split a numeric
literal like this:

a = 123\
456\
789L

The actual numbers I want to use are a few hundred digits, so
splitting them across several lines would be nice.

Is there another way to do this?  I guess I could enter

a = long("123"+
  "456"+
  "789")

but that does an extra runtime conversation instead of just
compiling the literal into the .pyc file.



More information about the Python-list mailing list