The data structure you want to use is a dictionary - known as hashmap or
hash or map in other languages. Lets say you have a few objects of type
town that you want to access using their zip, then things could look like
this:

------------
class Town(object):
    def __init__(self, zip, cool_clubs):
        self.zip = zip
        self.colo_clubs = cool_clubs


towns = [Berlin(10439, ["Marietta", "ICON", "Bastart"]),
         Cologne(50000, ["Subway", "Stadtgarten", "Gebäude 9"])]

index = {}
for town in towns:
     index[town.zip] = town
----------------

Hope that makes it clear to you - look into the tutorial for a chapter about
python data structures.


-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to