while (assignment):

Michele Simionato mis6 at pitt.edu
Tue Jul 29 18:44:19 CEST 2003

Sybren Stuvel <sybrenUSE at YOURthirdtower.imagination.com> wrote in message news:<slrnbicopb.6gh.sybrenUSE at sybren.thirdtower.com>...
> 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

First answer: DON'T DO THAT!!

Second answer: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/202234



More information about the Python-list mailing list