[Python-talk] Python encapsulation?
kent37 at tds.net
Tue Jun 12 22:18:53 EDT 2007
Alex Hewitt wrote:
> Lucky me I've found myself needing to learn Java for my day job. The
> current topic is encapsulation which in Java is largely achieved by
> declaring variables/methods as public or private. Does something like
> this exist in Python?
Not really. By convention, attributes with names starting with a single
underscore are implementation details, to be used at your peril. Names
starting with two underscores are somewhat hidden from clients but this
is more to prevent name collisions than for protection from prying eyes.
A bit more here:
More information about the Python-talk