Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 18 Nov 2005 14:32:46 +1100, Ben Finney wrote: > > 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? > > That's precisely how I understand "constant" to be useful.
The Python docs don't really talk about such a thing. However, the None name cannot be re-bound. Is that all that's required to have a "constant" in Python? If so, it's part of the assignment statement, and not something the object itself can decide. True? > > 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? Really hoping someone can come up with an answer for this. > > Is it bad style to make a user-defined class that creates > > immutable objects? Why? > > I can't see why it would be bad style. That's what FrozenSet does. "from foo import *" is supported in the language, but is still bad style. FrozenSet was *added* to the language (2.2), so that's evidence that Guido thinks it's a good idea. But I'd still like direct discussion: is making one's class instances immutable bad style? -- \ "Say what you will about the Ten Commandments, you must always | `\ come back to the pleasant fact that there are only ten of | _o__) them." -- Henry L. Mencken | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list