Why does python not have a mechanism for data hiding?

Fuzzyman fuzzyman at gmail.com
Thu Jun 5 09:26:54 EDT 2008


On Jun 3, 6:54 pm, sturlamolden <sturlamol... at yahoo.no> wrote:
> On May 24, 3:41 pm, Sh4wn <luckyluk... at gmail.com> wrote:
>
> > first, python is one of my fav languages, and i'll definitely keep
> > developing with it. But, there's 1 one thing what I -really- miss:
> > data hiding. I know member vars are private when you prefix them with
> > 2 underscores, but I hate prefixing my vars, I'd rather add a keyword
> > before it.
>
> Python has no data hiding because C++ has (void *).
>
> Python underscores does some name mangling, but does not attempt any
> data hiding.
>
> Python and C has about the same approach to data hiding. It is well
> tried, and works equally well in both languages:
>
>    # this is mine, keep your filthy paws off!!!
>
> Irresponsible programmers should not be allowed near a computer
> anyway. If you use data hiding to protect your code from yourself,
> what you really need is some time off to reconsider your career.

So, you are stating that no API programmer using Python *ever* has a
valid or genuine reason for wanting (even if he can't have it) genuine
'hiding' of internal state or members from consumers of his (or
her...) API?

Michael Foord
http://www.ironpythoninaction.com/



More information about the Python-list mailing list