lists v. tuples

Duncan Booth duncan.booth at invalid.invalid
Mon Mar 17 17:03:18 CET 2008


Ninereeds <stephenhorne100 at aol.com> wrote:

> On Mar 17, 1:31 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> 
>> A common explanation for this is that lists are for homogenous
>> collections, tuples are for when you have heterogenous collections i.e.
>> related but different things.
> 
> I interpret this as meaning that in a data table, I should have a list
> of records but each record should be a tuple of fields, since the
> fields for a table usually have different forms whereas the records
> usually all have the same record layout.

That is indeed what Python's Database API usually does (although it doesn't 
mandate it):

        .fetchmany([size=cursor.arraysize])
          
            Fetch the next set of rows of a query result, returning a
            sequence of sequences (e.g. a list of tuples). An empty
            sequence is returned when no more rows are available.





More information about the Python-list mailing list