A name refers to an object, an object has a value, equality compares values

Marko Rauhamaa marko at pacujo.net
Wed Nov 25 01:44:29 EST 2015


Ben Finney <ben+python at benfinney.id.au>:

> Indeed, in the past I used the term “value” as synonymous (in Python
> context) with the term “object”. I have become convinced through this
> discussion that I should no longer use the terms that way.
>
> [...]
>
> The concepts are distinct, so I apologise for misleadingly conflating
> them in my terminology.

I don't think the meaning of the word "value" can be restricted in that
way. Let's try to "refactor" the examples I had found in the wild:

  "How to get the value of a variable given its name in a string"
  => How to get the object a variable is bound to given the name of the
     variable in a string

  "The value of some objects can change. Objects whose value can change
  are said to be mutable"
  [no change]

  "I'm taking the return value of one function and using it as the
  argument of another function"
  => I'm taking the return object of one function and using it as the
     argument of another function

  "Don't get confused — name on the left, value on the right"
  => Don't get confused — name on the left, object on the right

  "We can print the current value of the dictionary in the usual way"
  [no change]

  "A return statement ends the execution of the function call and
  "returns" the result, i.e. the value of the expression following the
  return keyword, to the caller"
  => A return statement ends the execution of the function call and
     "returns" the result, i.e. the resulting object of the expression
     following the return keyword, to the caller

  "When we ask python what the value of x > 5 is, we get False"
  => When we ask python what the resulting object of x > 5 is, we get
     False

  "To display the value of a variable, you can use a print statement"
  => To display the value of the object a variable is bound to, you can
     use a print statement

  "Get a value of a specified key"
  => Get an image object of a specified key

In a word, it's a lost cause.

It is actually somewhat comical how Python documentation tries, but
fails, to maintain terminological orthodoxy:

  A mapping object maps hashable values to arbitrary objects. [...]

  A dictionary’s keys are almost arbitrary values. Values that are not
  hashable, that is, values containing lists, dictionaries or other
  mutable types (that are compared by value rather than by object
  identity) may not be used as keys.

  [...]

  Dictionaries can be created by placing a comma-separated list of
  key: value pairs within braces

  [...]

  The first object of each item becomes a key in the new dictionary, and
  the second object the corresponding value. If a key occurs more than
  once, the last value for that key becomes the corresponding value in
  the new dictionary.

  [...]

  d[key] = value
    Set d[key] to value.

  [...]

  values()
    Return a new view of the dictionary’s values.

  <URL: https://docs.python.org/3/library/stdtypes.html?highlig
  ht=value#mapping-types-dict>


Marko



More information about the Python-list mailing list