Why does python not have a mechanism for data hiding?

Joe P. Cool joe.p.cool at googlemail.com
Mon May 26 17:47:33 EDT 2008


On 26 Mai, 03:34, "Terry Reedy" <tjre... at udel.edu> wrote:
[...]
> | Please don't sell a missing feature as a philosophy.
>
> I won't if you don't claim that a feature is missing because you don't like
> its implementation.  To most of us, replacing the nearly never used '__'
> with a keyword would be a auful change.

With "missing" I simply meant "not there".


> | Please don't tell me that encapsulation does not mean "enforced
> restriction".
>
> There are obviously degrees of enforced restriction.  Take your TV example.
> Most users will respect a 'do not open' request by the manufacturer
> (Python's '_'.).

I program in Python quite often and I also use the '_' notation. But I
always found the inside/outside distinction very natural and
fundamental. The '_' notation is too informal and can arbitrarily be
overloaded with other meanings. I don't understand why it is so
important to avoid one keyword and paying for that by typing numerous
'_'. Underscore meaning is somewhat blurred - sometimes private,
sometimes protected. And it is line noise - like @$& in Perl.

> If you want something equivalent to epoxy embedding, design it, implement
> it, and share it (if you want).  Perhaps one could make an Opaque extension
> class, perhaps even usable as a mixin class rather than as a single-base
> class.

Perhaps I'll give it a try - as soon as I have found out what you
mean :)



More information about the Python-list mailing list