Does Python really follow its philosophy of "Readability counts"?
Paul Rubin
http
Sun Jan 11 18:41:51 EST 2009
Carl Banks <pavlovevidence at 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.
More information about the Python-list
mailing list