Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6708
| References | <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@mcgill.ca> <201105310713.24842.wolfgang@rohdewald.de> |
|---|---|
| Date | 2011-05-31 16:36 +1100 |
| Subject | Re: scope of function parameters (take two) |
| From | Daniel Kluev <dan.kluev@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2301.1306820195.9059.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: scope of function parameters (take two) Daniel Kluev <dan.kluev@gmail.com> - 2011-05-31 16:36 +1100
csiph-web