constructors for lists and tuples
Jeff Shannon
jeff at ccvcorp.com
Tue Dec 11 13:57:40 EST 2001
More information about the Python-list mailing list
Tue Dec 11 13:57:40 EST 2001
- Previous message (by thread): constructors for lists and tuples
- Next message (by thread): Newbie: Exeinstaller on win32 can't find my python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): constructors for lists and tuples
- Next message (by thread): Newbie: Exeinstaller on win32 can't find my python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list