Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6702 > unrolled thread
| Started by | Wolfgang Rohdewald <wolfgang@rohdewald.de> |
|---|---|
| First post | 2011-05-31 07:13 +0200 |
| Last post | 2011-05-31 07:13 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: scope of function parameters (take two) Wolfgang Rohdewald <wolfgang@rohdewald.de> - 2011-05-31 07:13 +0200
| From | Wolfgang Rohdewald <wolfgang@rohdewald.de> |
|---|---|
| Date | 2011-05-31 07:13 +0200 |
| Subject | Re: scope of function parameters (take two) |
| Message-ID | <mailman.2296.1306818800.9059.python-list@python.org> |
On Dienstag 31 Mai 2011, Henry Olders wrote: > What I would like is that the variables which are included in > the function definition's parameter list, would be always > treated as local to that function (and of course, accessible > to nested functions) but NOT global unless explicitly defined > as global. This would prevent the sort of problems that I > encountered as described in my original post. the parameter is local but it points to an object from an outer scope - that could be the scope of the calling function or maybe the global scope. So if you change the value of this parameter, you change that object from outer scope. But the parameter itself is still local. If you do def fnc2(c): c = 5 the passed object will not be changed, c now points to another object. This is different from other languages where the "global" c would change (when passing c by reference) what you really seem to want is that a function by default cannot have any side effects (you have a side effect if a function changes things outside of its local scope). But that would be a very different language than python did you read the link Steven gave you? http://mail.python.org/pipermail/tutor/2010-December/080505.html -- Wolfgang
Back to top | Article view | comp.lang.python
csiph-web