sturlamolden wrote:
On 20 Jul, 18:27, Phillip B Oldham <phillip.old...@gmail.com> wrote:

We're not looking to start any arguments or religious wars and we're
not asking that python be changed into something its not. We'd simply
like to understand the decision behind the lists and tuple structures.
We feel that in not "getting" the difference between the two types we
may be missing out on using these data structures to their full
potential.

A crude simplification would be:

- A Python programmer will use a tuple where a C programmer will use a
struct.

- Python and C programmers use lists and arrays similarly.

Tuples are used for passing arguments to and from a function. Common
use of tuples include multiple return values and optional arguments
(*args).

It has already been mentioned that tuples are immutable and can be
used as dictionary keys.


I think collections.namedtuple, introduced in Python 2.6, might help bridge the gap between a traditional tuple and a C struct.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to