Why does python not have a mechanism for data hiding?

topher Protectorates at gmail.com
Wed Jun 4 17:02:49 EDT 2008


On Jun 4, 2:58 pm, "Russ P." <Russ.Paie... at gmail.com> wrote:
> On Jun 4, 4:29 am, NickC <ncogh... at gmail.com> wrote:
>
> > On Jun 4, 4:09 am, "Russ P." <Russ.Paie... at gmail.com> wrote:
>
> > > What is it about leading underscores that bothers me? To me, they are
> > > like a small pebble in your shoe while you are on a hike. Yes, you can
> > > live with it, and it does no harm, but you still want to get rid of it.
>
> > With leading underscores, you can see *at the point of dereference*
> > that the code is accessing private data. With a "this is private"
> > keyword you have no idea whether you're accessing private or public
> > data, because the two namespaces get conflated together.
>
> That is true. But with the "priv" keyword you'll discover quickly
> enough that you are trying to access private data (as soon as you run
> the program). And even if a "priv" keyword is added, you are still
> free to use the leading underscore convention if you wish.
>
> The idea of being able to discern properties of an object by its name
> alone is something that is not normally done in programming in
> general. Yes, of course you should choose identifiers to be
> descriptive of what they represent in the real world, but you don't
> use names like "intCount," "floatWeight," or "MyClassMyObject" would
> you? Why not? That would tell you the type of the object at the "point
> of dereferencing," wouldn't it?

Sounds familiar.
http://en.wikipedia.org/wiki/Hungarian_notation



More information about the Python-list mailing list