associative array

Kushal Kumaran kushal.kumaran+python at gmail.com
Wed Mar 31 18:52:14 CEST 2010


On Wed, Mar 31, 2010 at 10:10 PM, Javier Montoya <jmontoyaz at gmail.com> wrote:
> Dear all,
>
> I'm a newbie in python and would be acknowledge if somebody could shed
> some light on associative arrays.
> More precisely, I would like to create a multi-dimensional associative
> array. I have for example a list of students which are identified
> uniquely by their student IDs. Additionally, for each student I have
> some information: FirstName, LastName, etc.
>
> The array would have then the following form:
> [StudentID] => [FirstName][LastName][Telephone]...[ ... ]
>
> I would like to be able to access a field directly by using a
> StudentID
> [StudentID][FirstName]
> [StudentID][LastName]
>
> How could I manipulate such an array (create the array, add elements,
> access data)?
>

Did you try the python tutorial?  Dictionaries might be what you are
looking for.

http://docs.python.org/tutorial/datastructures.html#dictionaries

-- 
regards,
kushal



More information about the Python-list mailing list