osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about the definition of the value of an object


Hello everyone,

I've been looking for something in the documentation
(https://docs.python.org/3.8/reference/datamodel.html) recently
and I've noticed something weird. Documentation states that every
object has a value, but doesn?t provide any definition
whatsoever of what the value is. Now, I'm sure that every reasonably
fluent Python programmer has an intuitive
understanding of the term, nonetheless, I would expect the
documentation defines it somehow (not necessarily
in a formal fashion), especially considering that "the value of an
object" is used to explain other concepts, such as
mutability:

> The value of some objects can change. Objects whose value can change are said to be mutable; objects whose
value is unchangeable once they are created are called immutable.

So, why is documentation silent on this? One reason I can think of is
to avoid answering inconvenient questions.
For example, while it is trivial that the value of an object of type
"bool" (either object "True" or object "False") is
either truth or falsity, but what about tuples? For the tuple "(a, b,
c)", is the value {"a", "b", "c"} or ("a", "b", "c")?
In another words, does the value retain information about the order? I
would think so, since "(a, b, c) != (a, c, b)"
but it's not obvious if we define value as "all the data the object
holds" or something similar. Same question can
be extended to things such as lists, dictionaries or - even more
problematic - user-defined types.

Moreover, there are paragraphs in the documentation where the word
"value" is used in different,
seemingly confusing, contexts:

> Ellipsis
> This type has a single value. There is a single object with this value. This object is accessed through the literal ...
or the built-in name Ellipsis. Its truth value is true.

This would suggest that:
1. Value of a type is an object of that type (this one is pretty standard).
2. There is a single value of type "Ellipsis", which is the object
accessed via built-in name "Ellipsis".
3. Value of the object "Ellipsis" is a unique value denoting the
omission from speech or writing.

Do I have it all backwards or am I missing something obvious here?
Thank you.

Sincerely,
Iwo Herka