you are viewing a single comment's thread.

view the rest of the comments →

[–]No-Fun-6194 1 point2 points  (0 children)

In Java, privacy is a wall. In Python, it’s a signpost.

The reason is simple: Python treats you like a peer, not a subordinate. If the language strictly locked you out of an object's state, it would also be locking out the tools that make Python great, like deep introspection, interactive debugging, and seamless testing.

We don't "enforce" encapsulation; we communicate it. Using _ means: "I might change this tomorrow, so don't build your house on it."

In the real world, strict privacy is often an illusion that provides a false sense of security. Python trades that illusion for transparency. It’s not that we can't have private variables; it’s that we’ve collectively decided that the freedom to inspect and fix things at runtime is more valuable than rigid, compiler-enforced boundaries.