Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder5.news.weretis.net!feeder.news-service.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.04; 'wed,': 0.04; 'around.': 0.07; 'slice': 0.07; 'caller': 0.09; 'mutable': 0.09; 'object.': 0.09; 'am,': 0.14; 'modify': 0.14; 'wrote:': 0.14; 'callee': 0.16; 'shallow': 0.16; 'command': 0.19; 'header:In-Reply-To:1': 0.22; 'received:209.85.214.174': 0.23; 'received:mail-iw0-f174.google.com': 0.23; 'objects': 0.24; "what's": 0.24; '(not': 0.24; 'subject:data': 0.26; 'chris': 0.27; 'object': 0.27; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.28; 'subject:?': 0.29; 'list': 0.30; 'skip:( 20': 0.31; 'changed.': 0.31; 'called': 0.32; 'to:addr:python-list': 0.32; "isn't": 0.34; 'reference': 0.34; 'change': 0.34; 'there': 0.35; 'assignment': 0.35; 'subject:What': 0.35; 'subject:use': 0.35; 'plain': 0.36; 'list,': 0.36; 'two': 0.37; 'received:209.85': 0.37; 'exactly': 0.37; 'references': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'i.e.': 0.40; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'safe': 0.65; 'share': 0.67; 'guarantee': 0.75; 'subject:other': 0.84 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=r9Q2SZXEuRmLU6c+d1ZPeIw64tdUSKTirB8qr2easRU=; b=DAOQhj7C1izlzAkCzDBshmtDjU5AX/PxFg+2/zdUYcu3a30VOVjKtPjWYOzqffCY9p fCF7SQC1U6vcWnyTRQiYfQYTgVXgH55wN3E4TBok1xdAcpqg/0+BY6efdFotpkW9fy6E NdOWewjqwtrzhbcKuunXLClC4CrOoiboIQ7Ug= 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=GOAZLb5LrN50xQoV56zdAiTbLj0YqIaMoRnL+0ESmwdYv5sPW/Paz0b0E4chn+M6QD LXOUedBDAzG357VuBnq6KEVSsAcpF8yAI/Sb7X09bxTH0VO1W9KjnVGOFIG+p5+ZBI3B 713O6CfHIp6OjWdAFLsiKepfjul7M9/beopkU= MIME-Version: 1.0 In-Reply-To: <876698-vjj.ln1@svn.schaathun.net> References: <4dbd1dbf$0$29991$c3e8da3$5496439d@news.astraweb.com> <876698-vjj.ln1@svn.schaathun.net> Date: Wed, 4 May 2011 08:00:35 +1000 Subject: Re: What other languages use the same data model as Python? From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304460047 news.xs4all.nl 41110 [::ffff:82.94.164.166]:35293 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4578 On Wed, May 4, 2011 at 6:47 AM, Hans Georg Schaathun wrote: > This looks like plain old transmission by reference to me. > I.e. the functions get a reference to an object and make any > change to the object. "Reference" being exactly what's passed around. There are now two references to that object. Since names always contain references (not objects), it's very easy to share mutable objects (lists/dictionaries/etc). There's an easy way for a caller or callee to guarantee that a mutable is safe - just slice it: identify_call(my_list[:]) That gives the called function a shallow copy of the list, which it can modify to its heart's content, but the original list isn't changed. Callee can do the same, with an assignment command at the top of the function (a_list=a_list[:]). Chris Angelico