[Tutor] Table like array in Python

Gloom Demon gloomdemon at gmail.com
Wed Mar 26 09:47:23 CET 2008


Hello :-)

I am reading Ivan van Leiningem "Learn Python in 24 hours" and I am having
problems understanding the way arrays work in Python. I used to know Pascal
and arrays there were tablelike.

Example (cost of something in different countries by different years)

Record1 US 2006 22.10
Record2 US 2007 23.45
Record3 UK 2007 22.90
..................................
RecordN ....................

So I could read the record, see if the name of the country in the first cell
was what I was looking for and either continue working with the record or
resume searching.

However in Python, if I understand correctly this example would look like
this:

US 2006 22.10 US 2007 23.45 UK 2007 22.90 ........................

This means that I have to keep a lot of unnesessary information in RAM, not
to mention that I would have to scan through the whole array instead
of scanning just the required cell.

Could anyone please direct me to a good description of working with arrays
in Python?
And I have problems understanding what dictionaries are for :-(

Thank You!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080326/e1236fd1/attachment.htm 


More information about the Tutor mailing list