Andy Dustman wrote:
> #########################################33
> #! /usr/bin/env python
> import MySQLdb
> db=MySQLdb.connect(host='localhost', db='photum_0_6_2', user='root',
> passwd='thkhgfgd')
> c=db.cursor()
> c.execute('select person from persons order by person')
> for (person,) in c: # or c.fetchall() (may be more portable)
> print person
> ################################################
> 
> If you return more than one column, then you don't need the parentheses
> for the tuple unpacking.

You don't need the parentheses for one element either:

for person, in c:
    print person

works perfectly. Note the trailing comma.

Georg
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to