[Tutor] List of Objects?

Karthik Gurumurthy karthikg@aztec.soft.net
Fri, 1 Feb 2002 03:27:51 +0530


> class Rooms:
     def __init__(self, name, desc, exits):
            self.name = name
            self.desc = desc
            self.exits = exits

> but this seems awfully tedious. It seems like creating an array of
> rooms would be much easier. I know that Python doesn't support arrays,
> and using a list would be the way to go. However, I'm not sure how to
> create a list of objects. Could anyone point me in the right direction?

params = [ [name1,desc1,exits1],[name2,desc2,exits2],[name3,desc3,exits3]]

listofRooms = map(lambda params:apply(Rooms,params),params)

is this ok?

karthik.