Compared to C++, Python object oriented support lacks of the modifiers private and protected. Even if you can prefix an internal member with a double underscore, this is merely cosmetic. Nothing prevents accessing these variables from outside. The reason behind this is that Python developers are "adult programmers". In other words, this feature has been introduced with in mind an experienced, disciplined and conscious developer. If this is not the case, there's no enforcement that can be provided by the language to avoid the creation of utter crap (cit.).

This consideration came to my mind few days ago while I was speaking with my colleague Paolo about coding styles and development rules. A guide and some rules are surely needed, but being too strict is counterproductive. For example, if you fix a maximum number of lines per function and you don't tolerate infractions, developers will pack multiple statements on each row or they will create silly functions with the only purpose of respecting the rule. Needless to say that the increase of readability of having short functions will be completely lost.

I can provide several examples but I think you got the point. Style guides cannot consider every situation and there will be exceptions. Rules that contain the words "always" and "never" are rarely respected in the real world. This is usually known as the difference between theory and practice. What is required to a programmer is to be disciplined enough to respect rules but smart enough to know when it's time to break them.


Image by Ibai taken from Flickr licensed under the Creative Commons Attribution 2.0 Generic license.