pretty basic instantiation question

Leif K-Brooks eurleif at
Tue Oct 24 01:40:01 CEST 2006

sittner at wrote:
> let's say i have a class, and i need to create a different number of
> instances (changes every time - and i can't know the number in advance) in
> a loop.
> a function receives the number of instances that are needed, and creates
> them like,
> a=Myclass()
> b=Myclass()

def create_instances(n):
     return [Myclass() for i in xrange(n)]

More information about the Python-list mailing list