Why does python not have a mechanism for data hiding?
Russ.Paielli at gmail.com
Thu Jun 5 21:37:39 CEST 2008
On Jun 5, 12:20 pm, Roy Smith <r... at panix.com> wrote:
> All somebody has to do to get at the private data is:
> #define private public
> # include <MySecretClass.h>
> #undef private
Well, that shows the weakness of the C/C++ header files. The "include"
directive merely does a simple text substitution, which is pretty lame
as far as I am concerned. As you say, Java has moved beyond that, and
Ada has always been more sophisticated than that.
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. But your point is still valid.
More information about the Python-list