Explanation of list reference

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Feb 15 07:48:37 CET 2014


On Sat, 15 Feb 2014 17:07:17 +1100, Chris Angelico wrote:

> On Sat, Feb 15, 2014 at 4:36 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> 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? 

[snip discussion]

You may be right. I will have to think about it a little more. Or a lot 
more. Ah wait, I got it: I chose a bad example for the expression. Here 
is a better one:

myobj.alist[12]["some key"].attribute


I think it is fair to call that both an expression and a reference.



-- 
Steven



More information about the Python-list mailing list