Why does python not have a mechanism for data hiding?

Roy Smith roy at panix.com
Sun Jun 8 10:34:07 EDT 2008


In article <slrng4nlfq.ihm.mdw at metalzone.distorted.org.uk>,
 Mark Wooding <mdw 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.

I think that's taking it a bit far.  Python doesn't let you manipulate 
pointers directly.  For example, I can't do:

   s = "foo"
   sp = address(s)
   sp[2] = 'x'
   print s

and have it print "fox".  Is this because I'm too stupid to make rational 
decision of this sort?  No, it's because the Python programming model 
exposes some things and hides others which are deemed inappropriate or too 
low level.  One of the things it hides is direct access to raw memory.  I 
don't see that as fundamentally different from a C++ string class which 
declares its internal buffer to be private.  If the goose's pot is black, 
then the gander's kettle is an equal shade of dark grey.



More information about the Python-list mailing list