On Sun, Jan 11, 2009 at 3:41 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > Carl Banks <pavlovevide...@gmail.com> writes: <snip> >> 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.
Regarding the second question, Python adheres to the principle that "We're all consenting adults here" and so does not provide complete encapsulation like more B&D languages. This is handy sometimes as it allows one to break through the encapsulation when necessary and fiddle with the internals. This is not to say that breaking encapsulation willy-nilly is advised, but it does allow for some neat hackery every now and again. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list