On Tue, May 31, 2011 at 4:13 PM, Wolfgang Rohdewald
<wolfg...@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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to