Something like this?

class User:
        def __init__(self, name):
                self.name = name
        def __str__(self):
                return self.name
n = 10
users = []

for i in range(n):
        users.append(User('user%d' % i))

print users[9]
print users[4]

Cheers,

Paul


On Sat, Jun 7, 2008 at 3:59 AM, Kalibr <[EMAIL PROTECTED]> 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?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to