Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'from:addr:yahoo.co.uk': 0.05; 'assignment': 0.07; '[1,': 0.09; 'before.': 0.09; 'mutable': 0.09; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'throws': 0.09; 'python': 0.10; 'value.': 0.15; '(there': 0.16; 'c++.': 0.16; 'inaccessible': 0.16; "isn't.": 0.16; 'python),': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'somewhere.': 0.16; 'subject:versus': 0.16; 'wrote:': 0.16; 'element': 0.18; 'integer': 0.18; 'refers': 0.18; 'python?': 0.18; 'language': 0.19; '>>>': 0.20; 'do.': 0.22; 'not,': 0.22; 'saying': 0.22; 'assign': 0.22; 'lawrence': 0.22; 'object.': 0.22; 'originally': 0.23; 'references': 0.23; 'replacing': 0.23; 'unlike': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'figure': 0.27; 'compare': 0.27; 'to?': 0.27; 'this.': 0.28; 'values': 0.28; 'referenced': 0.29; 'program,': 0.29; 'compared': 0.30; 'operations': 0.31; 'another': 0.32; "can't": 0.32; 'language.': 0.32; 'statement': 0.32; 'getting': 0.33; 'changed': 0.33; 'accessible': 0.33; 'instead,': 0.33; 'reference,': 0.33; 'values.': 0.33; 'changing': 0.34; 'list': 0.34; 'so,': 0.35; 'propose': 0.35; 'something': 0.35; 'list,': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; 'list.': 0.37; 'names': 0.38; 'copying': 0.38; 'mean': 0.38; 'end': 0.39; 'why': 0.39; 'whatever': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'still': 0.40; 'some': 0.40; 'address': 0.61; 'yes': 0.62; 'making': 0.62; 'is.': 0.63; 'different': 0.63; 'our': 0.64; "they're": 0.66; 'subjectcharset:utf-8': 0.71; '"can': 0.84; 'blown': 0.84; 'pythonistas,': 0.84; 'before?': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: =?UTF-8?B?UmU6IFRlcm1pbm9sb2d5OiDigJxyZWZlcmVuY2XigJ0gdmVyc3VzIA==?= =?UTF-8?B?4oCccG9pbnRlcuKAnQ==?= Date: Sat, 12 Sep 2015 07:05:06 +0100 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 195.147.66.69 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: 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: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442037928 news.xs4all.nl 23777 [2001:888:2000:d::a6]:60043 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96410 On 12/09/2015 06:42, Random832 wrote: > Ben Finney writes: >> The reference value is inaccessible to the program, it can only be used >> to get at the referenced object. > > That's like saying an integer is inaccessible since it can only be used > to add/subtract/etc (list of all operations you can do with an > integer). What does it mean to access something, if not to do some > operation on it? Getting the referenced object is the operation you can > do with it. > >>>> So in Python, we don't have pointers because we don't have access to >>>> change or reassign them. >>> >>> Yes you do. That's _exactly what happens_ in an assignment statement - >>> you are reassigning it to the address of another object. And that's >>> something you *can't do* with references in C++. >> >> The operation you describe doesn't change the reference; it doesn't >> mutate an existing value which can be compared with whatever value it >> had before. Instead, it throws away one reference and replaces it with a >> different one. > > So, if you have a list x, and assign a new value to x[0], it doesn't > change the list, because you can't compare the list to the value the > list had before? x still refers to a object which in this case happens to be a list. You've merely changed the value of the first element of the object that is referred to by the name x. > > You're not making any sense. It's a value. Changing it and "throwing > away and replacing with a different one" are the same thing. > >> That's significant, because unlike a mutable value you can never again >> get at the old reference in the Python program. > > I don't understand what you mean by "can never again get at" it if you > think you _can_ do it for mutable values. > >>>> You can't, for example, keep the old reference (there are no references >>>> to references in Python), because they're not accessible as values in >>>> themselves. Once you assign a different reference, the old one is gone >>>> and can't be found again. >>> >>> You can keep it by copying it to somewhere. >> >> How do you propose to “copy” a reference in Python? Making a new >> reference to the referenced object is not making a copy of the >> reference. > > Yes it is. I don't know why you think it's not, so I can't even figure > out how to respond to this. > No it isn't. When you make a copy of an object you will end up with two names that refer to the same object. >>> x = [1,2,3] >>> y = x >>> x;y [1, 2, 3] [1, 2, 3] >>> del x >>> y [1, 2, 3] If y was a copy of x, then when x is blown away how can y still know about the list that x originally referred to? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence