Bonjour,
En voulant approfondir le langage, je suis tombé sur ce cas :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
>>> larg,long=2,3
>>> p=[[(1, 2, 3), (1, 2, 3)], [(1, 2, 3), (1, 2, 3)], [(1, 2, 3), (1, 2, 3)]]
>>> q=[[(1,2,3)]*larg]*long
>>> p==q
True
>>> p[1][0]=(4,5,6)
>>> q[1][0]=(4,5,6)
>>> p==q
False
>>> p
[[(1, 2, 3), (1, 2, 3)], [(4, 5, 6), (1, 2, 3)], [(1, 2, 3), (1, 2, 3)]]
>>> q
[[(4, 5, 6), (1, 2, 3)], [(4, 5, 6), (1, 2, 3)], [(4, 5, 6), (1, 2, 3)]]
>>>
Si quelqu'un pouvait m'expliquer ou m'orienter.
Pourquoi ma manip sur q ne fonctionne pas comme avec p ?
NB : Je suis sous XP SP3 avec Python 2.7
Gérard