constructors for lists and tuples

janko hauser jhauser at ifm.uni-kiel.de
Tue Dec 11 09:03:07 EST 2001


one can not define empty list/tuples with a predefined length.
it is possible to create a sequence of a given length by multiplying a 
one element sequence.

>>> a=(1,)*3
>>> a
(1, 1, 1)

This is slighly more economic than appending or inserting to an empty
list.

>>> a=[]
>>> a.append(1)
>>> a
[1]

HTH,
__Janko




More information about the Python-list mailing list