while row = c.fetchone(): # syntax error???

Mike Fletcher mfletch at tpresence.com
Fri Aug 11 02:03:48 EDT 2000


Python explicitly disallows assignment in the conditional due to a broad
class of errors it tends to create.  About the simplest way to do it is:

value = c.fetchone()
while value:
	...
	value = c.fetchone()

There are any number of (huge) threads you can find on this all over the
place, there is little (no?) interest among the primary developers of Python
in "fixing" it.  Feel free to review those threads and see if you want to
try convincing people otherwise.

Enjoy,
Mike

-----Original Message-----
From: Thomas Gagne [mailto:tgagne at ix.netcom.com]
Sent: Thursday, August 10, 2000 11:20 PM
To: python-list at python.org
Subject: while row = c.fetchone(): # syntax error???


At the top of a while, the value of the function c.fetchone() is what I want
to evaluate, but I need to save the return value.  Whenever I try to code
this
I get a syntax error--python doesn't seem to like the assignment in the
conditional.  No amount of parens seem to make a difference.

Help?

-- 
http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list