List vs tuples

urnerk at qwest.net urnerk at qwest.net
Wed Apr 14 22:11:40 EDT 2004


<posted & mailed>

Isaac To wrote:

>>>>>> "John" == John Roth <newsgroups at jhrothjr.com> writes:
> 
>     John> It's a common question. A list is a data structure that is
>     John> intended to be used with homogenous members; that is, with
>     members John> of the same type.
> 
> I feel you argument very strange.  Even that it might be the original
> intention, I see nothing in the language that support your argument.
> 

In Python, lists don't care about members being homogenous.  There's a
less-used array type for that, in the standard library.  The principle
distinction between lists and tuples is indeed in the mutability
department.

As for emulating C structs, I liked the suggestion of using a class with
only data attributes.  That's a logical analogy, as in C++, it's the struct
that morphs into the basic class, with the addition of methods to data.

However, if you really want to used a low level C struct, there's actually a
struct in the standard library implemented using a C struct.  

Check out:

 >>> import struct
 >>> help(struct)

etc.

Kirby




More information about the Python-list mailing list