[Tutor] Instantiating large numbers of objects?

Britt Green cheshire_cat_sf@yahoo.com
Sat, 2 Feb 2002 16:29:48 -0800 (PST)

Hello Everyone,

Here is the problem I'm having: I've decided to write a very simple,
basic text adventure as a way of learning more about Python. For this
game I've created a simple class called Rooms. I'd like to know the
best way to instantiate several dozen of these rooms?

I know I could do something like:

theKitchen = Room(...)
thePorch = Room(...)
theWineCellar = Room(...)

but this seems cumbersome and it won't scale. I thought I could create
a list of Rooms but that seems like a cludge as well. I know that in C
I could create an array of objects and access them by their number.
Would doing something like this in Python be the best way to do this?
Or is there something else I should try?

Thanks to everyone who's helping me out. When I'm famous and wealthy, I
promise to remember you all! ;)


"The ocean, she is strange and wondrous, filled with animals that disturb even a Frenchman."

Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!