Kalibr wrote:
I've been developing a small script to fiddle with classes, and came
accross the following problem. Assuming I get some user input asking
for a number, how would I spawn 'n' objects from a class?
i.e. I have a class class 'user' and I don't know how many of them I
want to spawn.
Any ideas?
Sure. This will give you a list of n instances of user:
[user() for i in range(n)]
Of course, you could also use a good old for loop:
for i in range(n):
u = user()
...do something with u...
Hope this helps!
--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list