Hacker News new | ask | show | jobs
by xcoding 3512 days ago
Could you elaborate?
1 comments

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.