Immutability
Nick Maclaren
nmm1 at cus.cam.ac.uk
Wed Jun 28 12:40:32 EDT 2006
In article <mailman.7574.1151511089.27775.python-list at python.org>,
"Fredrik Lundh" <fredrik at pythonware.com> writes:
|>
|> identical? you only applied @property to one of the methods, and then you're
|> surprised that only one of the methods were turned into a property?
I wasn't expecting EITHER to be turned INTO a property - I was expecting
both methods to be the same, but one would have non-default properties
attached to it.
|> @property turns your "joe" method into a getter method for the (virtual) attribute
|> "joe". when you access the attribute, the getter method will be called. whatever
|> that method returns will be the attribute's value.
Ah! That clarifies a lot.
|> that's what the documentation
|> says, and that's what your code is doing.
Er, no, it doesn't. What it says may well be COMPATIBLE with that, but
it is compatible with a good many other interpretations, too. Until and
unless you know what it means, you can't extract its meaning from its
words.
Regards,
Nick Maclaren.
More information about the Python-list
mailing list