On Tuesday, November 24, 2015 at 12:25:54 PM UTC-5, Oscar Benjamin wrote: > On 24 November 2015 at 15:27, Ned Batchelder <n...@nedbatchelder.com> wrote: > > On Tuesday, November 24, 2015 at 10:10:51 AM UTC-5, Antoon Pardon wrote: > >> Op 24-11-15 om 15:18 schreef Ned Batchelder: > >> > >> > 2) In Python, "value" means, what object does a name refer to, or what > >> > object did an evaluation produce. > >> > >> I don't think this is correct because that would imply that objects don't > >> change values (since the value would be the object). > > > > Sorry, I should have been more precise. Python documentation suffers from > > this two-meaning world also. There are places where "value" is used in > > this second sense, perhaps more places than you realize. I know when I > > wrote "Python Names and Values", I meant it in this second sense. > > Hi Ned, I read your talk on this subject which was linked to further > up in the thread and it is excellent so thanks for that. I forwarded > it to a colleague for inspiration in our own introductory programming > (with Python) teaching unit. > > However when I read it and imagined explaining it to our students I > found myself wanting to adjust the terminology. I would not use the > word value in the way that you suggest. Rather I would want to > contrast "names" (or "references"), "objects" and "values". I think > that many things can be expressed more cleanly with these terms and I > think it corresponds more to the way in which I see Python programmers > use these terms. > > So I would say that an object has a value. Immutable objects have > unchanging values but the value of mutable objects can change. The > expression "a is b" determines whether or not a and b are bound to the > same object whereas "a == b" determines if the objects bound to a and > b have the same value. To copy an object is to create a new object > having the same value as the copied object. To mutate an object is to > change its value etc. > > Earlier in this thread you said: > """ > In Python, a default value expression > for a function argument is evaluated only once, when the function is defined. > That value (in this case, the actual list) is stored with the function. The > expression is not stored, the value of the expression is. That value (the > actual list) is supplied as the value of the argument if no other value is > supplied. If you modify that value in the function, the value is modified, > and used again at the next function call. > """ > I think that's a good example of where it would be clearer to > distinguish between objects and values, rather than using the word > value for both. In particular what is stored with the function is the > *object* that results from the default value expression. The *value* > of that object may change if it is mutated but it will still be the > same object each time the function is called (without a corresponding > argument being passed). > > -- > Oscar
Oscar, thanks for the thoughtful comments. I agree that using "object" for the result of an expression, and for the referent of a name, would go some ways to clarifying things. Perhaps the Python world uses "value" less to mean "object" than I am thinking. But we do talk about "the value of an expression", and "what value does X have," and so on. --Ned. -- https://mail.python.org/mailman/listinfo/python-list