Immutable instances, constant values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Finney

    #1

    Immutable instances, constant values

    Howdy all,

    I've recently packaged 'enum' in PyPI. In its description, I make the
    claim that it creates "immutable" enumeration objects, and that the
    enumeration values are "constant" values.

    This raises questions.

    Is there any difference between a Python immutable value, and a
    constant? I suppose "constant" also implies that the *name* binds
    unchangeably to a particular value. Is that meaningful?

    How does one actually ensure an object is immutable? Is it a matter of
    overriding a bunch of methods, or is ther a neater way?

    Is it bad style to make a user-defined class that creates immutable
    objects? Why?

    In the case of 'enum', can anyone argue for or against an enumerated
    type being immutable? Its values being constant?

    --
    \ "The best ad-libs are rehearsed." -- Graham Kennedy |
    `\ |
    _o__) |
    Ben Finney
Working...