Найти - Пользователи
Полная версия: Убрать ссылку на массив
Начало » Python для новичков » Убрать ссылку на массив
1
minotavr_x86
Как сделать так, что бы ссылки на массив не было?
a = [['']*3]*3
a[0][0] = 2
print a
>>[[2, '', ''], [2, '', ''], [2, '', '']]
kublo
a = [['' for i in range(3)] for j in range(3)]
bw
(1) >>> map(apply,
  • * 3)
    (2) >>> map(apply, itertools.repeat(list, 3))
    (3) >>> map(list, [ * 3] * 3)
    (4) >>> map(list, itertools.repeat( * 3, 3))

    ..bw
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB