Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6585
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Christopher Head <chead@is.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: scope of function parameters |
| Date | Sun, 29 May 2011 14:48:53 -0700 |
| Organization | solani.org |
| Lines | 35 |
| Message-ID | <20110529144853.2adff584@kruskal.chead> (permalink) |
| References | <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <201105291147.26545.wolfgang@rohdewald.de> <mailman.2237.1306700356.9059.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Trace | solani.org 1306705734 5644 eJwFwYkBADAEBLCZfIdxUPYfoYkJCOMKg9rZxdte7nnYdC1WKNGcZ4h4TUcSRRfvuVzb+yw4EZ4= (29 May 2011 21:48:54 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Sun, 29 May 2011 21:48:54 +0000 (UTC) |
| X-User-ID | eJwFwQkBACAIA8BK4xlqHATpH8E7WkjU8mA4h/Mm+9B4CnhLUm4SkboftsK1u0exSgp+2+IDIMcREw== |
| X-Newsreader | Claws Mail 3.7.8 (GTK+ 2.22.1; x86_64-pc-linux-gnu) |
| Cancel-Lock | sha1:aFcdqbSrPaSJdNY7tp42ejMJEhE= |
| X-NNTP-Posting-Host | eJwNyMEBwCAIA8CVjEDEcUBg/xHae54JwXeURrWxuXAexFuyEl0meGdfbSal6YTW9adqfce6babSLRLBDFTImpaA/71L4B+/PRpR |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:6585 |
Show key headers only | View raw
On Sun, 29 May 2011 16:19:11 -0400 Henry Olders <henry.olders@mcgill.ca> wrote: > > def fnc2(c): > > c = c[:] > > c[1] = 'having' > > return c > > Thank you, Wolfgang. That certainly works, but to me it is still a > workaround to deal with the consequence of a particular decision. > From my perspective, a function parameter should be considered as > having been assigned (although the exact assignment will not be known > until runtime), and as an assigned variable, it should be considered > local. > > Henry This has nothing to do with function parameters and everything to do with what a "variable name" actually means. You can get the same effect with only globals: >>> x=[1,2,3] >>> y=x >>> x.append(7) >>> y [1, 2, 3, 7] Why in the world does "y" end with 7, even though it was appended to "x"? Simple: because "x" and "y" are two names for the same list, as Henry explained. No functions involved, no locals, no parameters, no scoping. Again, if "y=x" were instead "y=x[:]" then the output would be "[1,2,3]" because "y" would refer to a copy of the list rather than the same list. Chris
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: scope of function parameters Henry Olders <henry.olders@mcgill.ca> - 2011-05-29 16:19 -0400 Re: scope of function parameters Christopher Head <chead@is.invalid> - 2011-05-29 14:48 -0700
csiph-web