Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.python > #7700

liste e liste di liste

Path csiph.com!aioe.org!.POSTED!not-for-mail
From germano <a@b.invalid>
Newsgroups it.comp.lang.python
Subject liste e liste di liste
Date Sun, 27 Nov 2016 12:16:09 +0100
Organization Aioe.org NNTP Server
Lines 27
Message-ID <o1ef9t$tgn$1@gioia.aioe.org> (permalink)
NNTP-Posting-Host cokiNovw9RtjwostAJwxdw.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Thunderbird 2.0.0.22 (Windows/20090605)
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com it.comp.lang.python:7700

Show key headers only | View raw


Se io scrivo

 >>> a=1; b=2; l=[a,b]
 >>> l
[1, 2]
 >>> a=0
 >>> l
[1, 2]

se invece scrivo

 >>> a=1; b=2; c=3; d=4; m=[a,b]; n=[c,d]; l=[m,n]
 >>> l
[[1, 2], [3, 4]]
 >>> a=0
 >>> l
[[1, 2], [3, 4]]
 >>> m[0]=0
 >>> l
[[0, 2], [3, 4]]

ovviamente si può risolvere scrivendo
l=[m[:],n[:]]

ma non mi è chiara la ragione che ci sta dietro, cioè perchè nel caso di 
una variabile semplice viene passato il valore, mentre nel caso di una 
lista si passa il puntatore creando questo legame tra l e m

Back to it.comp.lang.python | Previous | NextNext in thread | Find similar


Thread

liste e liste di liste germano <a@b.invalid> - 2016-11-27 12:16 +0100
  Re: liste e liste di liste Andrea D'Amore <anddam+NOSPAM@brapi.net> - 2016-11-27 14:10 +0100
    Re: liste e liste di liste germano <a@b.invalid> - 2016-11-29 12:08 +0100

csiph-web