Style question - defining immutable class data members
matthew at woodcraft.me.uk
Sun Mar 15 16:05:04 CET 2009
"Rhodri James" <rhodri at wildebst.demon.co.uk> writes:
> On Sun, 15 Mar 2009 13:26:17 -0000, Matthew Woodcraft
>> It seems clear to me that Maxim understood all this when he asked his
>> original question (you need to understand this subtlety to know why
>> the trick he was asking about only works for immutable values).
> It seems equally clear to me that Maxim didn't understand any of this
> when he asked his original question, since he appeared to view class
> attributes purely as initialisers.
Not at all.
He said: << Look, here's a tricky way to use a class attribute as an
initialiser. Is this good style? >>.
What was there in his post that makes you think he viewed class
attributes purely as initialisers?
> Given that either of us could be right, Gary's assumption of less
> understanding rather than more is clearly the safer one to take.
As a general rule, making that assumption runs the risk of being rude or
patronising, so the respondent should be very careful how to phrase the
response. c.l.py is friendlier than many newsgroups, but it could still
do much better.
But in this particular case, statements like
> However, you appear to have either a misuse or misconception of the
> word "immutable' here. Whether the value you assign to a class
> attribute is mutable or immutable is irrelevant.
are wrong as well as unhelpfully phrased.
More information about the Python-list