strings in Python (newbie)

Alex Martelli aleax at aleax.it
Fri Mar 14 06:21:39 EST 2003


zif wrote:

> Thanks, I'll try that as well. Another question: how
> can I break long text/array elements across multiple
> lines?

If I'm reading your question correctly, the answer is
easy -- Python concatenates multiple adjacent "physical"
lines into a single "logical" line as long as an open
parens (or bracket) hasn't yet been closed.  So for ex:

longstuff = [ 0, 1, 45, 67, 223, 23,
              15, 43, 88, 99, 1, 0,
              23, 24, 42, 15, 0, 2 ]

just works.  Note that indentation is arbitrary for all
the physical lines except the first one (also known as
"continuation lines") -- the one I'm showing here is just
one reasonably popular convention (there are others, too).


Alex





More information about the Python-list mailing list