Why does python not have a mechanism for data hiding?
wuwei23 at gmail.com
Tue Jun 3 07:23:52 CEST 2008
On Jun 3, 2:11 pm, "Russ P." <Russ.Paie... at gmail.com> wrote:
> Yes, that looks interesting, but I think it has a couple of drawbacks.
> First, it requires another completely separate class for the
> "implementation" (although perhaps that could be a nested class).
That's hardly an enormous overhead, and it does clearly separate the
interface you want your "users" to have from the implementation. Even
better, since you seem so concerned with others meddling with your
implementation directly, they could provide their own quite easily if
they so choose.
> Secondly, I think it essentially just adds a sort of inner namespace
> through which the "private" data is accessed. That might be a good
> idea, but I don't think it's quite the same as encapsulation.
It's a clear separation of concerns, check. It removes the underscored
methods you find so aesthetically offensive, check. I have absolutely
no idea what _you_ mean by "encapsulation".
Then again, I have no issue with the current convention and personally
find the idea of adding a "private" keyword makes as much sense as
being able to syntactically define "model", "view" and "controller"
More information about the Python-list