variable assignment in "while" loop

Sybren Stuvel sybrenUSE at YOURthirdtower.imagination.com
Tue Jul 29 08:08:50 EDT 2003


Hi there,

Is it possible to use an assignment in a while-loop? I'd like to do
something like "loop while there is still something to be read, and if
there is, put it in this variable". I've been a C programmer since I
was 14, so a construct like:

while info = mydbcursor.fetchone():
	print "Information: "+str(info)

comes to mind. Unfortunately, this doesn't work. Is there a similar
construct in python?

Sybren

PS: This is a supersede. If it didn't work out and you saw two
messages with the same content, please ignore the oldest one.
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 




More information about the Python-list mailing list