Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; 'jan': 0.12; 'subject:skip:u 10': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; '[1]': 0.29; 'am,': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; '13,': 0.31; 'url:python': 0.33; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'url:mail': 0.40; '2015': 0.84; 'joel': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=IPSWDUUP0nuMV2NZ3UCg67oTDrF0dzAhIRnYZyLwfSQ=; b=xVXZiFKEOKhDNKTRW9yTT4FelIDTG/YEGNLTx83aNzPOjKY2xpSKLIUMdS8PPi6h0T gO83LhQMBMa1Lm2mTOwSa3z7XyD1mEjGEZzMz366VcQKWMMBvebRwfmJJmPNQEa94hex zWTXGfggMUlo3CSVeCHx3mIkG2l4KUpssohL89zv9M/WsCMClGM92AMhX+4gN3ZAyc2e fcbAX5JS6FaGnxoAdZobfhM4CnfS5ohX0nIXkeCWl08/EmSggEimsZw5hVoQCPvPxCqk mWJ0uczFst4CvyZ5A5Hte8jjiopgtUW7m58SFPsxpAROrdbp5R8eD9Q3AzWCigP6fM91 ONEQ== MIME-Version: 1.0 X-Received: by 10.140.109.97 with SMTP id k88mr55274020qgf.99.1421156386291; Tue, 13 Jan 2015 05:39:46 -0800 (PST) In-Reply-To: References: Date: Tue, 13 Jan 2015 08:39:46 -0500 Subject: Re: Help understanding list operatoins inside functions in python 3 From: Joel Goldstick Cc: "python-list@python.org" Content-Type: multipart/alternative; boundary=001a113a701e934981050c88c157 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 76 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421156389 news.xs4all.nl 2866 [2001:888:2000:d::a6]:33299 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83689 --001a113a701e934981050c88c157 Content-Type: text/plain; charset=UTF-8 On Tue, Jan 13, 2015 at 7:51 AM, wrote: > I'm a bit confused why in the second case x is not [1,2,3]: > > x = [] > > def y(): > x.append(1) > > def z(): > x = [1,2,3] > > y() > print(x) > z() > print(x) > > Output: > [1] > [1] > x in the outer scope is not x in the z() scope > -- > https://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com --001a113a701e934981050c88c157 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Tue, Jan 13, 2015 at 7:51 AM, <stephen.boulet@gmail.com= > wrote:
I'm a bit confused= why in the second case x is not [1,2,3]:

x =3D []

def y():
=C2=A0 =C2=A0 x.append(1)

def z():
=C2=A0 =C2=A0 x =3D [1,2,3]

y()
print(x)
z()
print(x)

Output:
[1]
[1]

x in the outer scope is not x in th= e z() scope=C2=A0
--
https://mail.python.org/mailman/listinfo/python-list



--
--001a113a701e934981050c88c157--