why does the % string format operator only take tuples?
Roy Smith
roy at panix.com
Wed Apr 4 08:30:14 EDT 2001
"Alex Martelli" <aleaxit at yahoo.com> wrote:
> lists are homogeneous, tuples need not be
But python is perfectly happy to have heterogeneous lists:
>>> foo = [1, 'two', type(3)]
>>> foo
[1, 'two', <type 'int'>]
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? :-)
More information about the Python-list
mailing list