Paul Rubin a écrit :
Carl Banks <pavlovevide...@gmail.com> writes:
The criticism is very valid. Some languages do support immutable
variables (e.g. "final" declarations in Java, "const" in C++, or
universal immutability in pure functional languages) and they do so
precisely for the purpose of taming the chaos of uncontrolled
mutation. It would be great if Python also supported immutability.
I don't think what you said (which is fine) makes his criticism valid,
unless you also suggest that all objects should be immutable.
It would be enough to have a way to make specific objects and instance
attributes immutable.
If any objects are mutable, you have to be prepared for objects to
mutated outside the initializer.
Sure, but why have mutable objects all over the place? And, why
always have attributes visible at all, outside the class definition?
The approach in C++ and Java is to have public and private instance
variables, where the private ones are visible only in the class methods.
Why on earth are you using Python if you don't like the way it work ???
--
http://mail.python.org/mailman/listinfo/python-list