"private" variables a.k.a. name mangling (WAS: What is print? A function?)

Sion Arrowsmith siona at chiark.greenend.org.uk
Tue Jan 25 07:38:50 EST 2005


Jeremy Bowers  <jerf at jerf.org> wrote:
> [ ... ] the Python community, and in general the dynamic language
>community, has become increasingly confident that private variables don't
>solve *real* problems.

Years of writing and maintaining others' C++ and Java code (plus
one year of maintaining Python code and rather more writing) has
led me to believe that there is no justification for truly private
variables. "protected" yes, I can see the argument for, but
denying derived classes full access to your inner workings just
leads to clumsier (less readable and more bug-prone) implementations
derivations. (The same applies to Java's "final".) And it's based on
the hubris that you are a better programmer than anyone who might
want to extend your class and can forsee all circumstances in which
it might be subclassed.

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list