sequence of objects

Neal D. Becker ndbecker2 at
Wed Oct 13 17:09:57 CEST 2004

What is the recommended way to create a sequence of objects?  Assume the
objects have a default constructor:

class X:
  def __init__(self):

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