<html>
<body>
At 04:58 PM 11/29/2004, Jeff Peery wrote:<br>
<blockquote type=cite class=cite cite="">Hello, <br>
&nbsp;<br>
was wondering how python handles multi-line code. for example if I have a
really long equation and I don't want to have to scroll over to look at
it, can I just continue the equation on the next line? is this good
practice? similarly can I do this for things like dictionaries and
lists?</blockquote><br>
 From the Python Language Reference:<br><br>
2.1.5 Explicit line joining <br><br>
Two or more physical lines may be joined into logical lines using
backslash characters (\), as follows: when a physical line ends in a
backslash that is not part of a string literal or comment, it is joined
with the following forming a single logical line, deleting the backslash
and the following end-of-line character. For example: <br><br>
<pre>if 1900 &lt; year &lt; 2100 and 1 &lt;= month &lt;= 12 \
&nbsp;&nbsp; and 1 &lt;= day &lt;= 31 and 0 &lt;= hour &lt; 24 \
&nbsp;&nbsp; and 0 &lt;= minute &lt; 60 and 0 &lt;= second &lt;
60:&nbsp;&nbsp; # Looks like a valid date
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1

</pre>A line ending in a backslash cannot carry a comment. A backslash
does not continue a comment. A backslash does not continue a token except
for string literals (i.e., tokens other than string literals cannot be
split across physical lines using a backslash). A backslash is illegal
elsewhere on a line outside a string literal. <br><br>
2.1.6 Implicit line joining <br><br>
Expressions in parentheses, square brackets or curly braces can be split
over more than one physical line without using backslashes. For example:
<br><br>
<br>
<pre>month_names = ['Januari', 'Februari',
'Maart',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # These are the
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'April',&nbsp;&nbsp; 'Mei',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'Juni',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Dutch names
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'Juli',&nbsp;&nbsp;&nbsp; 'Augustus', 'September',&nbsp; # for the
months
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'Oktober', 'November', 'December']&nbsp;&nbsp; # of the year

</pre>Implicitly continued lines can carry comments. The indentation of
the continuation lines is not important. Blank continuation lines are
allowed. There is no NEWLINE token between implicit continuation lines.
Implicitly continued lines can also occur within triple-quoted strings
(see below); in that case they cannot carry comments. <br><br>
2.4.1 String Literals<br>
...<br><br>
In triple-quoted strings, unescaped newlines and quotes are allowed
<br><br>
Thus:<br>
&nbsp;&quot;&quot;&quot;this is a<br>
multiline string&quot;&quot;&quot;<br><br>
That should cover it<br>
<x-sigsep><p></x-sigsep>
Bob Gailer<br>
bgailer@alum.rpi.edu<br>
303 442 2625 home<br>
720 938 2625 cell</body>
</html>