4 ms·
Objects can be mutable or immutable. The value of a mutable object can change to another value, but it's not that the value-in-itself is mutable. http://docs.p
by dvanduzer 13y ago
Objects can be mutable or immutable. The value of a mutable object can change to another value, but it's not that the value-in-itself is mutable.
http://docs.python.org/3/reference/datamodel.html#objects-values-and-types http://docs.python.org/3/reference/datamodel.html#objects-va...
- lmm 13y agoSo can I declare an enum value to be e.g. a list? Is that value "frozen" when the enum declaration is processed or what?
- dvanduzer 13y agoA list is not a value, it is a type of object. The second to last paragraph of the section in the reference manual I linked may help: Some objects contain references to other objects; these are called containers. Examples of containers are tuples, lists and dictionaries. The references are part of a container’s value. In most cases, when we talk about the value of a container, we imply the values, not the identities of the contained objects; however, when we talk about the mutability of a container, only the identities of the immediately contained objects are implied. So, if an immutable container (like a tuple) contains a reference to a mutable object, its value changes if that mutable object is changed. PEP-435 says enums are bound to "unique, constant values" -- not that you can bind enums to arbitrary types of objects.