On Tue, 29 Jan 2013 22:14:42 -0800, Daniel W. Rouse Jr. wrote:

> "John Gordon" <gor...@panix.com> wrote in message
> news:keaa9v$1ru$1...@reader1.panix.com...

>> A tuple is a linear sequence of items, accessed via subscripts that
>> start at zero.
>>
>> Tuples are read-only; items cannot be added, removed, nor replaced.
>>
>> Items in a tuple need not be the same type.
>>
>> Example:
>>
>>    >>> my_tuple = (1, 5, 'hello', 9.9999)
>>    >>> print my_tuple[0]
>>    1
>>    >>> print my_tuple[2]
>>    hello
>>
> To me, this looks like an array. Is tuple just the Python name for an
> array?

Absolutely not. Arrays can be modified in place. Tuples cannot. Arrays 
can be resized (depending on the language). Tuples cannot. Arrays are 
normally limited to a single data type. Tuples are not.

Python lists are closer to arrays, although the "array" type found in the 
array module is even closer still.

You create lists either with the list() function, or list builder 
notation using [ ].

Tuples are intended to be the equivalent of a C struct or Pascal record. 
Lists are very roughly intended to be somewhat close to an array, 
although as I said the array.py module is even closer.


>> A dictionary is a mapping type; it allows you to access items via a
>> meaningful name (usually a string.)
[...]
> Thank you, I understand it better it is kind of like a hash table.

Correct. Also known as "associative array".


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

Reply via email to