Why does python not have a mechanism for data hiding?
Russ.Paielli at gmail.com
Mon Jun 9 20:43:19 CEST 2008
On Jun 9, 2:22 am, Bruno Desthuilliers <bruno.
42.desthuilli... at websiteburo.invalid> wrote:
> > Does
> > anyone object to not having access from outside a function to local
> > variables within the function? I doubt it. The other thing is that the
> > vast majority of Python software, I would guess, is provided with
> > source code. How many Python applications or libraries are provided
> > without source code? If you have the source code, you can obviously
> > just delete the "priv" keyword anywhere or everywhere it appears.
> Yes, fine. And then have to maintain a fork of the source code, and
> distribute it with the application. Honking great idea. doh :-(
A client who wishes to bypass access restrictions need not maintain
any "fork." If you have access to the source code, removing my
proposed "priv" keyword from an entire library or application is a one-
liner in sed.
If you wish to remove only specific instances of its occurrences, that
is also a trivial matter, and all that needs to be maintained by the
client is a record of which instances were removed. In fact, the
client doesn't even need to do that, because when the next version
comes out they will be reminded very quickly of where they removed
But such a client would be a real fool for depending on private data
and/or methods, of course, because those are not part of the public
API and are not guaranteed to remain unchanged. The whole reason for
private data and methods is that they give the developers freedom to
change the implementation without changing the interface.
How about some common sense here. If you, the client, are convinced
that something declared private should really be public, then perhaps
you should contact the developer and explain your reasoning. If the
developer agrees, then the problem is solved. If not, then perhaps it
is *you*, the client who does not understand the proper usage of the
I don't have time to reply to all or your claims, but my lack of a
reply to any particular point should not be construed as implicit
More information about the Python-list