On 09/07/17 02:56, Mats Wichmann wrote: > From OO people, though, we get the sputtering But... But... what about > encapsulation, data hiding, etc?
Encapsulation isn't really an issue here since Pythons classes fully encapsulate their data and methods. They just make them both public. Data Hiding is the issue for some OO purists, especially those who learned OO via C++/Java. But data hiding was never originally enforced by the language, when Parnas wrote his seminal paper there were very few languages that explicitly supported making module data (he wasn't writing about OO at the time) private. Instead data hiding was achieved by providing such a powerful and complete set of API functions that there was no temptation to play with the supporting data. Python adheres to that philosophy, although for "simple" attributes it does allow, and even encourage, direct access. But in most cases we, as class designers, should be striving to provide sufficiently powerful methods that nobody needs to mess with the internal state directly. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
