[Tutor] Line Continuation Confusion

Robertson, David S. DRobertson@Covenant.com
Sat Jul 26 00:22:02 2003


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C3532D.50243610
Content-Type: text/plain


Greetings and thanks to all.  Although I have been programming for many
years, I am new to Python; this list has already been a great help in
climbing the learning curve!  Now my question:

I have read several books about line continuation in Python, and I am told
consistently that "Python also joins adjacent physical lines into one
logical line if an open parenthesis ((), bracket ([), or brace ({) has not
yet been closed."  ("Python in a Nutshell", Alex Martelli, O'Reilly)  

But when I try to run the following code, I get complaints from Python
unless I use backslashes at the end of each line.  Why doesn't the open
parentheses after "execute" hold the statement open until the closing
parentheses?

oCursor.execute("SELECT count(*) 
		FROM SchoolPlans  
		WHERE SchoolsId = 1;")

(BTW: I have, of course, tried making this statement all one line:  it works
great.  It just ain't very readable!)

Many thanks in advance.
_david







------_=_NextPart_001_01C3532D.50243610
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>Line Continuation Confusion</TITLE>
</HEAD>
<BODY>
<BR>

<P><FONT SIZE=3D2>Greetings and thanks to all.&nbsp; Although I have =
been programming for many years, I am new to Python; this list has =
already been a great help in climbing the learning curve!&nbsp; Now my =
question:</FONT></P>

<P><FONT SIZE=3D2>I have read several books about line continuation in =
Python, and I am told consistently that &quot;Python also joins =
adjacent physical lines into one logical line if an open parenthesis =
((), bracket ([), or brace ({) has not yet been closed.&quot;&nbsp; =
(&quot;Python in a Nutshell&quot;, Alex Martelli, O'Reilly)&nbsp; =
</FONT></P>

<P><FONT SIZE=3D2>But when I try to run the following code, I get =
complaints from Python unless I use backslashes at the end of each =
line.&nbsp; Why doesn't the open parentheses after &quot;execute&quot; =
hold the statement open until the closing parentheses?</FONT></P>

<P><FONT SIZE=3D2>oCursor.execute(&quot;SELECT count(*) </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>FROM =
SchoolPlans&nbsp; </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>WHERE =
SchoolsId =3D 1;&quot;)</FONT>
</P>

<P><FONT SIZE=3D2>(BTW: I have, of course, tried making this statement =
all one line:&nbsp; it works great.&nbsp; It just ain't very =
readable!)</FONT>
</P>

<P><FONT SIZE=3D2>Many thanks in advance.</FONT>
<BR><FONT SIZE=3D2>_david</FONT>
</P>
<BR>
<BR>
<BR>
<BR>
<BR>

</BODY>
</HTML>
------_=_NextPart_001_01C3532D.50243610--