Encapsulation unpythonic?

Fabrice Pombet fp2161 at gmail.com
Sun Sep 1 06:09:59 EDT 2013


 > That said, though, when you consider the language ecosystem rather
> 
> than just the language, there is a strong tendency for Java and C++
> 
> code to wrap everything up with functions (no public data members),
> 
> whereas Python code is far more likely to have external code directly
> 
> access data inside an object. You usually will find Java code calling
> 
> methods to change members, whereas that's done in Python only when
> 
> there's a need for it.


Yep, this is precisely my point, if you take encapsulation as a philosophical principle, Java and C++ would tend to be abiding by it, as a "default" setting that you can at times change, whereas python would tend to be the contrary. In other words, you can set some encapsulation if and when you want to, but you can leave your code without it when it's not needed/inconvenient. So I guess that we are actually all agreeing on this one.




More information about the Python-list mailing list