constructors for lists and tuples
Jeff Shannon
jeff at ccvcorp.com
Tue Dec 11 13:57:40 EST 2001
Rene Jensen wrote:
> If you would want a list of initialized objects, do this:
>
> MyList = [None] * size
> MyList = map(lambda x:MyClass() , MyList)
For Python 2.x, you can use a list comprehension:
MyList = [MyClass() for x in range(size)]
I find myself liking list comps more and more all the time. :)
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list