[Tutor] List of Objects?

Kirby Urner urnerk@qwest.net
Thu, 31 Jan 2002 19:45:01 -0800


>
> > 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.

However, re-expressed with a for-loop, it's not so
dense, and just as good:

params = [ ("great hall","where trolls live",3),
            ("dungeon","not a fun place",0),
            ("tower room","where she sleeps",1)]

listofRooms = []

for p in params:  listofRooms.append(apply(Rooms,p))


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

And since we've been discussing it:

listofRooms = [apply(Rooms,p) for p in params]

also works.

Kirby