On 6/17/07, Marcpp <[EMAIL PROTECTED]> wrote: > On 17 jun, 03:53, Dan Hipschman <[EMAIL PROTECTED]> wrote: > Hi, I need to return a tupla like this function: > > def BDllids(a): > a = () > conn = sqlite.connect('tasques.db') > cursor = conn.cursor() > cursor.execute('SELECT * FROM tasques') > for row in cursor: > a.append (row[0]) > return a() > > I'm doing the correct, method?
Tuples are immutable (can't be modified once created). Try this: def BDllids(): conn = sqlite.connect('tasques.db') cursor = conn.cursor() cursor.execute('SELECT * FROM tasques') a = [row[0] for row in cursor] return tuple(a) Is there some particular reason you need to return a tuple as opposed to a list? P.S. Accessing fields of a SELECT * by numeric index is prone to breakage if the order of your fields changes. You can make your code more robust by either specifying the column name explicitly in the SELECT statement. Alternatively, you may be interested in the sqlite.Row object (see the documentation for details). -- David -- http://mail.python.org/mailman/listinfo/python-list