sequence of objects
Neal D. Becker
ndbecker2 at verizon.net
Wed Oct 13 11:09:57 EDT 2004
What is the recommended way to create a sequence of objects? Assume the
objects have a default constructor:
class X:
def __init__(self):
something
This doesn't work:
a = 64*(X(),)
This creates a tuple of 64 copies of a single identical object, not 64
instances of X.
I could create an empty list, then call append (X()) 64 times, but that's
not very eligant (or maybe efficient). Any suggestions?
More information about the Python-list
mailing list