Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'assignment': 0.07; 'cc:addr:python-list': 0.11; '"object': 0.16; '9:13': 0.16; 'assignment.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'implies': 0.16; "objects'": 0.16; 'other,': 0.16; 'posted.': 0.16; 'substitute': 0.16; 'valid.': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'sorry,': 0.24; 'regardless': 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'extension': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'context.': 0.31; 'object.': 0.31; 'yes.': 0.31; 'something': 0.35; 'case,': 0.35; 'definition': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'largely': 0.36; 'vice': 0.36; 'doing': 0.36; 'possible': 0.36; 'changing': 0.37; 'being': 0.38; 'depends': 0.38; 'pm,': 0.38; 'does': 0.39; 'new': 0.61; 'simple': 0.61; "you're": 0.61; 'first': 0.61; 'name': 0.63; 'therefore,': 0.64; 'holding': 0.65; 'situation': 0.65; 'between': 0.67; 'therefore': 0.72; 'proves': 0.84; 'absolutely': 0.87; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=7ikpYldAhekbsw5TP9XlR5EL8O9TP7uoLewcp/Vc/XM=; b=Ypjj035idnSgW7iFV8oLqmtw307+4YDDFC8d0v6FKvSXdSM8DI7AZVHwpXFgPIgk66 qwb3Ac7qwds/DrP0PehgfNFuGCcD7n8aGJc6ZbRua7CLtteyEM/rn0w1SXOIjVa/q0lL 3a4kp4CPSSh19IRv5tqzsW5dUPnUb8+P/HqTz4ObDIIlCzCtLyJoUL2feDfXcvRj1W1C EEyctT1mUIAELIaLAdzNIT561s7KXHCiOEoGyh895MJVRnV44gXJhOKjYvJXBqgQ5wXK f0cUOEyw3dhIHeUH1SIsGnXg7mwQLl9SJiFJKKb+iyIbKeADtVXop6JykmkJmjMK+MzL FQCQ== MIME-Version: 1.0 X-Received: by 10.68.162.66 with SMTP id xy2mr14931666pbb.46.1392463878515; Sat, 15 Feb 2014 03:31:18 -0800 (PST) In-Reply-To: <87mwhsn0nx.fsf@elektro.pacujo.net> References: <13208de8-0f85-4e60-b059-dc087c8fda41@googlegroups.com> <917ede6d-db7c-4a8c-8203-27677283776b@googlegroups.com> <871tz5piy0.fsf@elektro.pacujo.net> <87vbwho1i0.fsf@elektro.pacujo.net> <87mwhtnzdu.fsf@elektro.pacujo.net> <87y51cn2m9.fsf@elektro.pacujo.net> <87mwhsn0nx.fsf@elektro.pacujo.net> Date: Sat, 15 Feb 2014 22:31:18 +1100 Subject: Re: Explanation of list reference From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392463886 news.xs4all.nl 2868 [2001:888:2000:d::a6]:33686 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66417 On Sat, Feb 15, 2014 at 9:13 PM, Marko Rauhamaa wrote: > A new attempt: Sorry, hadn't seen this when I posted. > 0. x is x This is the definition of identity. > 1. if x is y then y ix x Yes, because if x is y, there is absolutely no difference between using one of those names or the other, in any context. > 2. if x is y and y is z then x is z Extension of the above. The first statement proves that you can substitute 'x' for 'y' in the second without changing its truthiness; therefore, based on the definition of identity, 'x is z' must be identical to 'y is z'. > 3. after x = y, x is y This is the definition of assignment. (Obviously this axiom depends on x and y being simple names and nothing tampering with the situation in any way. But yes, this is exactly what assignment is.) > 4. if x is y and x == x, then x == y Yes. As in case 2, 'x is y' implies that you can substitute 'x' for 'y' or vice versa. Therefore, if x == x, then y == y, and x == y, and y == x; because in each case, what you're doing is "object #1423443, are you equal to object #1423443 or not?", regardless of the name you use to access that object. > 5. id(x) == id(y) iff x is y This is the definition of id(). Note that it does depend on something holding a reference to each of x and y; if it's possible for the objects' lifetimes to not overlap, it's possible for them to reuse ids: >>> [1,2,3] is [2,3,4] False >>> id([1,2,3]) == id([2,3,4]) True But if x and y are simple names (and therefore retaining their referent objects), then your statement is valid. > Does that cover it? Largely axiomatically, yes. ChrisA