[Tutor] List of Objects?
Sean 'Shaleh' Perry
shalehperry@attbi.com
Thu, 31 Jan 2002 14:37:02 -0800 (PST)
On 31-Jan-2002 Karthik Gurumurthy wrote:
>
>> 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?
>
For an obfuscated python contest, sure. For newbie help I would say no.