tuple assign variables

dimitri pater dimitri.pater at gmail.com
Sat Aug 13 02:24:17 CEST 2005


Hello,
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):

def deep_list(x):
if type(x)!=type( () ):
return x
return map(deep_list,x)

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.
Any suggestions?

thanks,
Dimitri
-- 
All truth passes through three stages. First, it is ridiculed. Second, it is 
violently opposed. Third, it is accepted as being self-evident.
Arthur Schopenhauer 
-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050813/58155950/attachment.html>


More information about the Python-list mailing list