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


Groups > comp.lang.python > #6708

Re: scope of function parameters (take two)

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <dan.kluev@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(although': 0.05; 'args': 0.07; 'subject:two': 0.07; 'python': 0.08; 'subject:parameters': 0.09; 'pm,': 0.10; 'def': 0.12; 'received:209.85.214.174': 0.14; 'received:mail-iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'overrides': 0.16; 'rohdewald': 0.16; 'scope.': 0.16; 'subject:function': 0.16; 'wolfgang': 0.16; 'obviously': 0.17; 'tue,': 0.17; 'language': 0.18; 'wrap': 0.19; 'header:In-Reply- To:1': 0.21; 'modify': 0.22; 'function': 0.25; 'object': 0.26; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; '(you': 0.29; 'effect': 0.29; 'explicitly': 0.29; 'class': 0.29; 'changes': 0.30; 'seem': 0.32; 'done': 0.32; 'to:addr:python- list': 0.33; 'too': 0.33; 'things': 0.33; '...': 0.34; 'daniel': 0.34; 'function.': 0.35; 'or,': 0.37; 'received:google.com': 0.37; 'change': 0.37; 'received:209.85': 0.37; '(to': 0.37; 'ways': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'subject: (': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'best': 0.60; '31,': 0.65
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=1+jKP9y9iiRbg6zZBaZi2oVv7pWKSoRX/6XAyURso38=; b=xL89MfsQlxSyxgyJHYjNSfdqab6Ry/nmvOLioI2zj2hgjTFX7yuDUZdQLVF2EKuDYV ZP3Q1IcCxNNBIqRfHKV/MmgvrfU1KwHexxatQm3koViyTgKM23VTbqm5rH2QM9YrZTw2 PMhUCplFVWhNo3Gu2A+vl19pJ5gdr4GeVhGKU=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=l/a1/1UVytiFk1I8508W4SpwpczdX8o1dgZ0uuDPQHN3onL90fPXv/UmERnPcph1Dw DMAHPtnLqpCHYKuZo0GDlt3COcVHZbaGa/KOx9XEbzEF2UzZvfnFrN21Sxsd0RQZbsFg kK7tzZSYdnTE+ZuSJwUl2y8cm7AAaN2mdCkCE=
MIME-Version 1.0
In-Reply-To <201105310713.24842.wolfgang@rohdewald.de>
References <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@mcgill.ca> <201105310713.24842.wolfgang@rohdewald.de>
Date Tue, 31 May 2011 16:36:33 +1100
Subject Re: scope of function parameters (take two)
From Daniel Kluev <dan.kluev@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2301.1306820195.9059.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 82.94.164.166
X-Trace 1306820196 news.xs4all.nl 49182 [::ffff:82.94.164.166]:53952
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6708

Show key headers only | View raw


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


Thread

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

csiph-web