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


Groups > comp.lang.python > #83689

Re: Help understanding list operatoins inside functions in python 3

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 <joel.goldstick@gmail.com>
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&gt;': 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 <eb7dcc11-410d-44a9-b619-e5ae70876aa1@googlegroups.com>
References <eb7dcc11-410d-44a9-b619-e5ae70876aa1@googlegroups.com>
Date Tue, 13 Jan 2015 08:39:46 -0500
Subject Re: Help understanding list operatoins inside functions in python 3
From Joel Goldstick <joel.goldstick@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17672.1421156389.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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 = []
>
> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help understanding list operatoins inside functions in python 3 stephen.boulet@gmail.com - 2015-01-13 04:51 -0800
  Re: Help understanding list operatoins inside functions in python 3 Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-13 08:39 -0500
  Re: Help understanding list operatoins inside functions in python 3 Laurent Pointal <laurent.pointal@laposte.net> - 2015-01-13 14:43 +0100
  Re: Help understanding list operatoins inside functions in python 3 mortoxa <mortoxa@gmx.com> - 2015-01-14 00:49 +1100
  Re: Help understanding list operatoins inside functions in python 3 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-01-13 09:25 -0500

csiph-web