tuple assign variables
dimitri.pater at gmail.com
Sat Aug 13 02:24:17 CEST 2005
selecting a record from a MySQL database results in a tuple like this:
(('Evelyn', 'Dog', 'No'),)
I want to assign every item of that tuple to a variable using this code
(deep_list is taken from the Python Cookbook):
if type(x)!=type( () ):
mytuple = (('Evelyn', 'Dog', 'No'),)
mylist = deep_list(mytuple)
for item in mylist:
name, pet, modified = item
it woks fine, but I wonder if there is a better way to achieve this.
All truth passes through three stages. First, it is ridiculed. Second, it is
violently opposed. Third, it is accepted as being self-evident.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list