Tuples --> How to use them ?

Max M maxm at mxm.dk
Wed Jul 3 16:35:14 EDT 2002


Marcus Vinicius Laranjeira wrote:

> Supose I have an arbitrary tuple of values that came from a sql query. I 
> need to run this algorithm:
> 
> t1 <-- new tuple
> t1 <-- results from an arbitrary query
> l <-- new list
> for each value in the tuple do:
>     a <-- new tuple
>     add this value to the tuple a
>     add the tuple a to a the list l
> 
> i.e. I need to create a list of tuples and these tuples will have one, 
> and only one, number that came from the original tuple.

l = [(value,) for value in t1]

If I understand the problem correctly??

regards Max M




More information about the Python-list mailing list