Declare list of large size

Steve Holden sholden at holdenweb.com
Thu Mar 28 10:36:48 EST 2002


"Corrado Gioannini" <corrado.gioannini at nekhem.com> wrote
[ ... ]
> another way to build a mutable multidimensional array is simply
> >>> list = eval(repr([[0] * 2] * 2))
> avoiding the problem of multiple references to the same list object
>
> do you find it too dirty, unpleasant or un-pythonic?
> (i'm really asking, it's not an ironic question ;-] )
>
Very dirty! Somewhat unpleasant. My own view of its pythonicity is
about -0.5, though arguably it's a pragmatic solution for small data sets.
Building and evaluating a huge string isn't terribly good practice when
there are other ways to achieve the same end programmatically.

regards
 Steve







More information about the Python-list mailing list