Will python never intend to support private, protected and public?

Paul Rubin http
Thu Sep 29 00:23:07 CEST 2005


Gregor Horvath <g.horvath at gmx.at> writes:
> If its your code this is possible, but if not and the maintainer is
> not willing or able to change it, then you have a problem.

Perhaps the maintainer has good reason for not wanting to change it.
After all, he's maintaining the code and you're not.  In the course of
that maintenance he might change the internal usage of the private
variable that messes up the way you use it.  He's supposed to be
allowed to do that--that's why the variable is private.  Is he
supposed to get your permission every time he wants to change how the
private variables in his class work?

> The fact that in other languages there are wired tricks to get to
> private instance variables is a strong indicator that there is a need
> for that.

Java has some JVM switches that open ways to get at private variables
so things like debuggers can work.  In production code you'd turn that
stuff off.  And it's certainly not intended for normal classes in an
application to get at the private variables of other classes.

> Guided freedom is better than enforced authority.

The obvious way to provide that guidance is to declare variables to be
private if other classes shouldn't mess with the variables.  There is
still the freedom to change the declaration if necessary.  Unless of
course you don't have the source code.  Where there is no source code,
there is no freedom, no matter what features the language has.



More information about the Python-list mailing list