Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1a.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assign': 0.07; 'expressions': 0.07; 'result,': 0.07; 'skip:` 10': 0.07; '2000,': 0.09; 'attributes': 0.09; 'lst': 0.09; 'cc:addr:python-list': 0.11; 'bit.': 0.16; 'created.': 0.16; 'evaluates': 0.16; 'expressions,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; '15,': 0.26; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'said,': 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'steven': 0.31; 'another': 0.32; 'agree': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'yield': 0.36; 'so,': 0.37; 'two': 0.37; 'list': 0.37; 'pm,': 0.38; 'expect': 0.39; 'does': 0.39; 'itself': 0.39; 'sure': 0.39; 'even': 0.60; 'expression': 0.60; 'most': 0.60; 'new': 0.61; "you've": 0.63; 'refer': 0.63; 'anything.': 0.68; 'object:': 0.84; '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=535jWRMO1LmXhlFlLe7+BVHvXNXQY+CgZwRGeY8kPv8=; b=QlWGc/3LooSlKHlkg1oZF6ESJGOdKXNKLgOhypVAi5tQOH8imP/UVK2ldCbVAZZs+q 3fawroaG/0NziNZlYsnacHzsSC6b649qnfg8Ua8O1hZNeRCZq0UpT5MkIlu2R4lkCjRW 2LINoK7DxW1Ne1kVqiSZRZMSE+SstKa9ME+DmcYGLM4476l4163fjzLPfrmo1E0ruXRl bT3qV0xRMhnIbJuIM3VrFVGz08Z7kBF/++Jn3B9Vm0oUX0zyeY4SAGnjbRubkK3kXwTj pRk1Nq+d9T2FXnUAuOPQsIzJIZZgInE6YwQnvtuuD6pZNmITpuKRrRWkmFrDaDdT21id OytQ== MIME-Version: 1.0 X-Received: by 10.66.158.132 with SMTP id wu4mr13715542pab.66.1392444437683; Fri, 14 Feb 2014 22:07:17 -0800 (PST) In-Reply-To: <52fefccc$0$29973$c3e8da3$5496439d@news.astraweb.com> References: <13208de8-0f85-4e60-b059-dc087c8fda41@googlegroups.com> <52fefccc$0$29973$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 15 Feb 2014 17:07:17 +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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392444446 news.xs4all.nl 2882 [2001:888:2000:d::a6]:45853 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66376 On Sat, Feb 15, 2014 at 4:36 PM, Steven D'Aprano wrote: > References can be names like `mystring`, or list items `mylist[0]`, or > items in mappings `mydict["key"]`, or attributes `myobject.attr`, or even > expressions `x+y*(1-z)`. I agree with most of what you've said, but I'm not sure I like that last bit. The expression evaluates to an object, yes, but it's not itself a reference... is it? It has references to x, y, 1, and z, but it's not itself a reference to anything. If you take a reference and assign it to a name, and take that same reference and assign it to another name, I would expect those two names to now refer to the same object: >>> lst = [1000, 2000, 3000] >>> x = lst[1] >>> y = lst[1] >>> x is y True But with expressions, it's not so, and new objects may be created. The expression isn't a reference to its result, but it can yield an object, which it (naturally) does by reference. ChrisA