Line continuation for a string > 79 characters
sdm7g at Virginia.EDU
Wed Jan 9 13:50:39 EST 2002
On Wed, 9 Jan 2002, Paul Brian wrote:
> thank you, but my main aim was to make it quick and easy for me to cut and
> paste long file names in and out of scripts (I know I know, but I am doing a
> lot of quick and dirty exploration)
> So dividing up into '/somefile' and '/someotherfile' is more work than just
> having messy files
> I like the / v \\ idea - I'll try it.
> Overall I think I am stuck with the \ added onto the end of my lines. Oh
You don't need to break at path boundaries -- Berthold was just trying
to show you the cleanest looking way to do it.
 Python will automatically concatenate adjacent strings.
 Python will join lines that, according to the grammar, are obviously
incomplete, so you can split lists, tuples, dicts and parenthesised
expressions (like arg lists) over several lines without an ending
So there are a number of line continuation styles you can choose from:
>>> "abc" \
... "def" \
>>> ( "abc"
... "ghi" )
(and I'm sure there are more... )
-- Steve Majewski
More information about the Python-list