Why does python not have a mechanism for data hiding?

Matthieu Brucher matthieu.brucher at gmail.com
Thu Jun 5 16:12:55 EDT 2008


2008/6/5 Russ P. <Russ.Paielli at gmail.com>:

> 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.
>

And also

#define class struct
#include "something.h"
#undef class

;)

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080605/cad1ef02/attachment-0001.html>


More information about the Python-list mailing list