Why does python not have a mechanism for data hiding?

P

Paul Boddie

All I did was to suggest that a keyword be added to Python to
designate private data and methods without cluttering my cherished
code with those ugly leading underscores all over the place. I don't
like that clutter any more than I like all those semi-colons in other
popular languages. I was originally attracted to Python for its clean
syntax, but when I learned about the leading-underscore convention I
nearly gagged.

I'm not bothered about having private instance data, but I think
there's definitely a case to be answered about the double-underscore
name-mangling convention. In the remote past, people were fairly
honest about it being something of a hack, albeit one which had mostly
satisfactory results, and unlike the private instance data argument
which can often be countered by emphasising social measures, there has
been genuine surprise about this particular method of preventing
attribute name collisions - it's an issue which can trip up even
careful programmers.

Note also that the double-underscore convention is listed as a Python
wart [1] and is described by Kuchling thus:

"But it's a hack and a kludge; making privacy depend on an unrelated
property such as the attribute's name is clumsy. At least this
ugliness is limited to one specific and little-used case; few Python
programmers ever bother to use this private variable feature."

In my opinion there are too many people either defending the status
quo (warts and all) or pushing the envelope in many areas that didn't
overly bother people before (various Python 3000 features).

Paul

[1] http://wiki.python.org/moin/PythonWarts
 
M

Michele Simionato

Pardon, but I think you mean "experienced".

Of course, GvR may qualify as "experimented" if one considers
designing a language from scratch to be an experiment <G>

It looks like in French (as in Italian) *experimented* has the
meaning of "tried and tested on the field" when applied to a
person.

Michele Simionato
 
B

Bruno Desthuilliers

Dennis Lee Bieber a écrit :
Pardon, but I think you mean "experienced".

Indeed. Tim Golden already corrected me (in private) about my mistake.
Please pardon my french :-/
Of course, GvR may qualify as "experimented" if one considers
designing a language from scratch to be an experiment <G>

<g>++ ?-)
 
L

Luis Zarrabeitia

Quoting Dennis Lee Bieber said:
<Spock raised eyebrow>

Fascinating

Spanish also. I translate "experimentado" to "experienced", perhaps because I
had seen it before, but I never imagined that "experimented" would be wrong.

Fascinating x2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top