un-tuple (newbie)

Heather Coppersmith me at privacy.net
Mon Dec 1 06:58:36 EST 2003


On Mon, 01 Dec 2003 11:30:20 +0100,
Martin Doering <doeringm at gmx.de> wrote:

> # execute a query
> def query(db, sql):
>     c = db.cursor()
>     c.execute(sql)
>     for line in c.fetchall():
>         val = line
>         print val
>     c.close()
>     return val

> I could find out, how to create a tuple with just one member, but I
> can not find out how to get a value from a tuple with just one member.

The tuple's only member is it's "zeroth" element:

    print val[ 0 ]

HTH,
Heather

-- 
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli




More information about the Python-list mailing list