Newbie confused by 2 dimensional list
Peter Schneider-Kamp
nowonder at nowonder.de
Mon Aug 7 15:22:14 EDT 2000
Duncan Booth wrote:
>
> If you are desparate to avoid the for loop you can always do:
>
> >>> import copy
> >>> L = map(copy.copy, [["*"]*2]*2)
> >>> L[0][0] = '#'
> >>> L
> [['#', '*'], ['*', '*']]
A bit less desparate, but with lambda:
>>> L = map(lambda x:x[:], [["*"]*2]*2)
>>> L[0][0] = '#'
>>> L
[['#', '*'], ['*', '*']]
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter at schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de
More information about the Python-list
mailing list