From: Emiliano Date: 2001-10-24T17:17:16+09:00 Subject: [ruby-talk:23155] Re: Bruce Eckel's opinion of Ruby Rich Kilmer wrote: > > But it still wouldn't be the default behaviour. Having class-private > > data available publicly by default isn't correct in my book. You have > > to choose what to make part of your public interface. IMO, of course. > > In the following I am not trying to be anti-Python...just trying to set the record straight... > > Regarding "private" class variables. > > So...in Python you can use this: > > obj.__dict__['attrName']=value > > ...to get direct access to (get/set) the values of every attribute on an object. But reading this it is immediately clear to me you are violating the 'contract' the class provides. > In Ruby every object attribute is private and can only be accessed > through a method...period. Exposing the __dict__ "bag" on an object > exposes the entire state of that object for public consumption. Than I was mistaken in my believe that every attribute was publicly accessible. Emile