Dynamically naming objects.

stefaan.himpe stefaan.himpe at gmail.com
Sat Jun 7 06:57:55 CEST 2008


Hello,

You can use this as indicated by Hans:

>>    u = [user() for i in xrange(5)]

where "user" is a class or a function returning an object.
u then is a list of "user" objects.

> or does it somehow work? how would I address them if they all have the
> name 'u'?

You'd access members of the list as u[0], u[1], ... etc.
I think you'd benefit from reading an introductory programming book.

Best regards,
Stefaan.



More information about the Python-list mailing list