Why does python not have a mechanism for data hiding?

Russ P. Russ.Paielli at gmail.com
Sun Jun 8 15:27:14 EDT 2008


On Jun 8, 5:52 am, Mark Wooding <m... at distorted.org.uk> wrote:

> By enforcing your `data hiding', you're effectively telling me that I'm
> too stupid to make rational decisions of this sort.  And that's actually
> extremely insulting.

1) I suggest you not take it personally.

2) Local data within functions is hidden. Should you have access to
that too? Are you insulted that you don't?

3) I have suggested that "indirect" or "back door" access could be
provided to private data and methods via some sort of name mangling
rule akin to the current rule for leading double underscores. This
would provide access in a pinch, but it would make sure the client is
aware that he or she or it is accessing private data (and it would do
so without leading underscores).

4) My understanding is that most Python software is released or
shipped as source code (or at least with the source code included).
That means that the client would need only to remove my suggested
"priv" keyword to gain access. Have you ever actually had to use
Python software for which you had no access to the source code?



More information about the Python-list mailing list