FAQ
All,

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.

Does anyone know how do I do that !?

Marcus

## Search Discussions

•  at Jul 3, 2002 at 8:35 pm ⇧

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
•  at Jul 4, 2002 at 10:38 am ⇧

Marcus Vinicius Laranjeira wrote:

All,

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.

Does anyone know how do I do that !?

#creating new tuple is not necessary
t1=query()
l=[]
for value in t1:
l.append([value])

thomas

## Related Discussions

Discussion Overview
 group python-list categories python posted Jul 3, '02 at 7:26p active Jul 4, '02 at 10:38a posts 3 users 3 website python.org

### 3 users in discussion

Content

People

Support

Translate

site design / logo © 2022 Grokbase