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


Groups > comp.lang.python > #83697

Re: Help understanding list operatoins inside functions in python 3

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Help understanding list operatoins inside functions in python 3
Date 2015-01-13 09:25 -0500
Organization IISS Elusive Unicorn
References <eb7dcc11-410d-44a9-b619-e5ae70876aa1@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.17676.1421159409.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, 13 Jan 2015 04:51:19 -0800 (PST), stephen.boulet@gmail.com
declaimed the following:

>I'm a bit confused why in the second case x is not [1,2,3]:
>
>x = []
>
>def y():
>    x.append(1)

	MODIFY contents of object identified by the name "x"; "x" is not a
local name, search module (global) level to find it.

>
>def z():
>    x = [1,2,3]

	Create an anonymous list containing three elements; attach the LOCAL
name "x" to that list; never looks at module "x:
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious 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