Hi all,

First, let me preface this by the fact that I'm completely new to the 
language, but not to programming in general.

I'm trying to get my feet wet with something near and dear to my heart: 
database programming.  Here's what I've got:

import pgdb;

dbh = pgdb.connect(database = 'test')
sth = dbh.cursor()
sth.execute("SELECT * FROM capitals")
#while 1:
     #results = sth.fetchone()
     #if results == None:
         #break
     #print results
while results = sth.fetchone():
     print results

If I try to run the above code, I get a SyntaxError indicating that I 
can't do an assignment in the while loop.  I found a way around this 
(see the commented out while loop), but it seems hackish.  Assignment 
within a while loop seems like a pretty standard thing, so I'm just 
curious what I'm missing.

Thanks in advance,
Ben
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to