Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: 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; 'skip:[ 20': 0.03; 'resulting': 0.04; 'works.': 0.07; '[1,': 0.09; 'happen.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'variables': 0.15; 'example?': 0.16; 'pairs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:reference': 0.16; 'subject:versus': 0.16; 'thread.': 0.16; 'case.': 0.18; 'drawing': 0.18; 'skip:` 10': 0.18; 'ascii': 0.22; 'sorry,': 0.22; '(or': 0.23; "haven't": 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'followed': 0.27; 'question': 0.27; 'correct': 0.28; 'actual': 0.28; 'objects': 0.29; 'code': 0.30; 'mention': 0.30; 'skip:[ 10': 0.31; "i'd": 0.31; "can't": 0.32; 'received:comcast.net': 0.33; 'structure': 0.34; 'add': 0.34; 'list': 0.34; 'gives': 0.35; 'could': 0.35; 'clear': 0.35; 'something': 0.35; 'instead': 0.36; '(and': 0.36; 'subject:" ': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'say': 0.37; 'received:org': 0.37; 'doing': 0.38; 'wrong': 0.38; 'anything': 0.38; 'data': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'easy': 0.60; 'your': 0.60; 'skip:u 10': 0.61; 'provide': 0.61; 'show': 0.62; 'complete': 0.63; '>>>>>': 0.66; 'circle': 0.66; 'picture': 0.70 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Random832 Subject: Re: Terminology: "reference" versus "pointer" Date: Sat, 12 Sep 2015 17:27:51 -0400 References: <14afe27e-0bd5-410f-8e64-0f31d496ebf2@googlegroups.com> <55F36B4C.9020007@gmail.com> <1442016698.95299.381478313.2487CA0E@webmail.messagingengine.com> <85mvws6z45.fsf_-_@benfinney.id.au> <85io7g6xy4.fsf@benfinney.id.au> <85egi46wng.fsf@benfinney.id.au> <1a1a1f6a-27ce-4c1b-807a-43eabaa04abb@googlegroups.com> <04ca9d7c-d02b-4329-bd94-4d18d86b3edf@googlegroups.com> <87egi375wb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: c-68-39-146-59.hsd1.in.comcast.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:Z0Xc4GoJ7n9Y8vEnSjmbuSQVvj0= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442093281 news.xs4all.nl 23789 [2001:888:2000:d::a6]:35615 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96461 Akira Li <4kir4.1i@gmail.com> writes: >Rustom Mody writes: >> viz. I have two variables (or names!) say a and b which look the same >>>>> a >> [[1,2],[1,2]] >>>>> b >> [[1,2],[1,2]] >> And yet doing >>>>> a[0][0] = "Oops!" >> gives a data structure one "Oops!" >> whereas doing it to b mysteriously gives 2 > > Sorry, I haven't followed the whole thread. Could your provide a > complete code example? Mention what you expect to happen and what > happens instead in your case. a0 = a1 = [1, 2] b0 = [1, 2] b1 = [1, 2] a = [a0, a1] b = [b0, b1] del a0, a1, b0, b1 There's nothing about *him* expecting anything wrong to happen. The question is how to draw a diagram that unambiguously shows the resulting structure using the "parcel tags" model shown in the diagrams (and without having a0/a1/etc as actual names) It's easy to draw such a diagram for the "boxes and arrows" model: (@ shows the box named by a[0][0]. Or a[1][0].) a[*]-->[*]----v [*]-->[@]--------->(1) [*]-. ^^ `--------++--. b[*]-->[*]-->[*]----------'| | [*]-. [*]-----------+-.| v | || [*]--------------' vv [*]--------------->(2) If the "parcel tags" model can't show it, then the "parcel tag" model clearly is not a correct and complete depiction of how Python actually works. (If I were drawing a picture rather than ASCII I'd add something to make it clear that the pairs shown are list objects Like, it's a circle with the word "list" and two pointer-boxes inside it.)