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

References <eb7dcc11-410d-44a9-b619-e5ae70876aa1@googlegroups.com>
Date 2015-01-13 08:39 -0500
Subject Re: Help understanding list operatoins inside functions in python 3
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17672.1421156389.18130.python-list@python.org> (permalink)

Show all headers | 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