News for hackers. Stuff that matters.
Re:Ask HN: What is encapsulation in Python? by probinso on Saturday November 05, 2016 @02:29PM (#12881131)
Encapsulation in object oriented programming is a term we use to describe joining of conceptual topics. A class generally models a conceptual topic, the data and methods on the class allow a clean interface to operations from that topic.

This extends the idea that 'the existence of a public method acts a documentation for what you can do with a object`. The existence of private methods and data are only to the benefit of the developer of the class.

Python's standards for encapsulation are a little different, because you cannot hide methods and data the same way you would with other languages. This is made apparent with public interfaces to private methods like in .__iter__(self): methods.

There are no comments on this comment yet.