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


Groups > comp.lang.python > #6708 > unrolled thread

Re: scope of function parameters (take two)

Started byDaniel Kluev <dan.kluev@gmail.com>
First post2011-05-31 16:36 +1100
Last post2011-05-31 16:36 +1100
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.


Contents

  Re: scope of function parameters (take two) Daniel Kluev <dan.kluev@gmail.com> - 2011-05-31 16:36 +1100

#6708 — Re: scope of function parameters (take two)

FromDaniel Kluev <dan.kluev@gmail.com>
Date2011-05-31 16:36 +1100
SubjectRe: scope of function parameters (take two)
Message-ID<mailman.2301.1306820195.9059.python-list@python.org>
On Tue, May 31, 2011 at 4:13 PM, Wolfgang Rohdewald
<wolfgang@rohdewald.de> wrote:
> 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

This can be done in Python (to some degree), like this

@copy_args
def somefunc(a, b, c):
     ...

where copy_args would explicitly call deepcopy() on all args passed to
the function.
Or, to save some performance, wrap them in some CopyOnEdit proxy
(although this is tricky, as getattr/getitem can modify object too if
class overrides them).

Obviously it would not save you from functions which use
global/globals() or some other ways to change state outside their
scope.

-- 
With best regards,
Daniel Kluev

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web