[Tutor] lists vs dicts

Erik Price erikprice@mac.com
Wed, 27 Mar 2002 07:58:49 -0500


I have a quick question --

I understand lists (and tuples) to be what I call numerically-indexed 
arrays.  And dictionaries to be associatively-indexed arrays.  Is there 
ever a compelling reason to use one over the other?  In other words, if 
I am referring to a finite array of say, six elements, and it helps me 
to assign English indexes to these elements rather than 0 thru 5, it's 
okay to use a dictionary, right?  (Even if I don't plan to -do- anything 
with these English index names.)  I see lists being useful for things 
like arrays where you may not know the number of elements that may be 
generated, etc.  But there's no reason to choose a list over a 
dictionary if I have no interest in the number order of the array, right?

A rhetorical question to help me decide which type to use when -- I'm 
used to being able to access an array by its numeric index OR its 
associative index.

Thanks,

Erik