why does the % string format operator only take tuples?

Steve Holden sholden at holdenweb.com
Wed Apr 4 11:23:48 EDT 2001


"Roy Smith" <roy at panix.com> wrote in message
news:roy-8D8CD4.08301404042001 at news.panix.com...
> "Alex Martelli" <aleaxit at yahoo.com> wrote:
> > lists are homogeneous, tuples need not be
>
Actually, Alex wrote that the above was the Haskell interpretation.

> But python is perfectly happy to have heterogeneous lists:
>
> >>> foo = [1, 'two', type(3)]
> >>> foo
> [1, 'two', <type 'int'>]
>
Of course.

> On the other hand, if you consider that to be a convention, it does at
> least explain why, for example, the DB-API has fetchall() returning a list
> of tuples: each individual row is heterogeneous (tuple), but the
collection
> of rows themselves is homogeneous (list).
>
> I've been wondering about that for three years.  Is there anything else
you
> guys havn't told me? :-)
>
There's a huge amount, but you'll have to join the Python Secre





More information about the Python-list mailing list