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 !?

thanks in advance,

Marcus

Search Discussions

  • Max M 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
  • Thomas Guettler 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 Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 3, '02 at 7:26p
activeJul 4, '02 at 10:38a
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase