Where's the List?

Peter Otten __peter__ at web.de
Sat Jun 5 16:30:18 EDT 2010


Victor Subervi wrote:

> Where's the list? They're both tuples in that last line of code.

>     for order in order_details:
>       store = order[0]
>       prodid = order[1]
>       pkg = order[2]
>       quantity = order[3]
>       if 'PatientID' in order_fields:
>         patientID = order[4]
>         try:
>           option_values = order[5:]
>         except TypeError:
>           option_values = []

Here...

>         sql = 'insert into orders%s values (Null, %s)' % (store, ",
> ".join("%s" * (4 + len(option_values))))
>         cursor.execute(sql, tuple([pkg, prodid, tmpTable, quantity] +
> option_values))
>       else:
>         patientID =  ''
>         try:
>           option_values = order[4:]
>         except TypeError:
>           option_values = []

there...

>         sql = 'insert into orders%s values (Null, %s)' % (store, ",
> ".join("%s" * (4 + len(option_values))))
> #        cursor.execute(sql, tuple([pkg, prodid, tmpTable, quantity,
> order[4], order[5]]))
>         cursor.execute(sql, tuple([pkg, prodid, tmpTable, quantity] +
> option_values))
> 
> It throws this error:
> 
> *TypeError*: can only concatenate list (not "tuple") to list
>       args = ('can only concatenate list (not "tuple") to list',)

everywhere?




More information about the Python-list mailing list