Why does python not have a mechanism for data hiding?

Russ P. Russ.Paielli at gmail.com
Fri Jun 6 03:09:40 CEST 2008

On Jun 5, 2:57 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> "Russ P." <Russ.Paie... at gmail.com> writes:
> > By the way, my recollection is that in C++ access defaults to private
> > if nothing is declared explicity. So normally the "private"
> > declaration is unnecessary. If it is left out, your little trick won't
> > work.
> How about #define class struct

I never thought of that one. I wonder what the C++ gurus would say
about that.

Let me guess. They'd probably say that the access restrictions are for
your own good, and bypassing them is bound to do you more harm than
good in the long run. And they'd probably be right. Just because you
can break into a box labeled "DANGER HIGH VOLTAGE," that doesn't make
it a good idea.

This just goes to show that the whole idea of using header files as
simple text insertions is flaky to start with, and adding the
preprocessor just compounds the flakiness. Needless to say, I'm not a
big fan of C and C++.

More information about the Python-list mailing list