Immutability
Robert Kern
robert.kern at gmail.com
Wed Jun 28 03:50:50 EDT 2006
Nick Maclaren wrote:
> The way that I read it, Python allows only values (and hence types)
> to be immutable, and not class members. The nearest approach to the
> latter is to use the name hiding conventions.
>
> Is that correct?
You can also make properties that don't allow writing.
class Foo(object):
def __init__(self, bar):
self._bar = bar
@property
def bar(self):
return self._bar
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list