Dynamically naming objects.

Alan Isaac aisaac at american.edu
Sat Jun 7 06:57:25 CEST 2008


> On Jun 7, 1:20 pm, Hans Nowak 
>>   [user() for i in range(n)]


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


users = list(User() for i in range(n))
for user in users:
        user.do_something()

hth,
Alan Isaac




More information about the Python-list mailing list