tuple.index()
Simon Brunning
simon at brunningonline.net
Thu Dec 14 07:20:12 EST 2006
On 12/14/06, Nick Maclaren <nmm1 at cus.cam.ac.uk> wrote:
> Well, if that were so, it would explain things. But lists AREN'T
> necessarily homogeneous!
>
> >>> a=[52,"abc",[1,2],5.6]
> >>> print repr(a)
> [52, 'abc', [1, 2], 5.5999999999999996]
It's not a technical restriction, as I said, but it's what lists are *for*.
Indeed, it *can't* be a technical restriction, because, as I said, by
'type' I wasn't referring to anything technical. A list might contain,
for example, "things to process". That's a conceptual kind of thing,
so the list is conceptually homogeneous, but technically speaking, the
list might contain instances of any class (or built-in type).
A good example of a tuple, OTOH, might be a database tuple, i.e. a row
returned from an RDBMS. Even if all the tables columns are of the same
type - say, strings - it doesn't mean that they are interchangeable.
Their position has semantic significance - it means something.
Make sense?
--
Cheers,
Simon B
simon at brunningonline.net
http://www.brunningonline.net/simon/blog/
More information about the Python-list
mailing list