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

Steven D'Aprano steve at REMOVETHIScyber.com.au
Thu Sep 29 16:16:02 CEST 2005

On Wed, 28 Sep 2005 22:07:56 -0700, Paul Rubin wrote:

>> One that is in other languages not even possible. A clear disadvantage.
>> Python gives me power and does not take it away like the others.
> Huh?  If my car has a "feature" that lets someone blow it to
> smithereens from hundreds of miles away without even intending to,
> that's somehow an advantage?

Funny you should mention that.

The other day I stopped at a service station to fill up. I noticed a line
of cars at a bowser over in the corner. The bowser was wrapped in a big
yellow tape saying "Caution!!! Warning!!! Experimental Petrol, for private
use only!!! USE AT OWN RISK!!! CAUTION CAUTION CAUTION Read the Manual
Before Using!!!"

So naturally I filled up with my car with this private petrol, because I
hoped that it would give me more power when accelerating.

Well, it certainly did that, wow you should have seen my car go! But alas
I should have read the manual first, just like they said. It turned out
that this experimental petrol contained an additive that did not suit my
car's engine. Three days later, smoke started pouring out of the engine
and then it caught fire.

I could have read the manual, which I later found out was aware of the
risk of fire and gave simple instructions for how to avoid it (adding a
cup of ethanol to a full tank of petrol was all it would have taken to
prevent the harmful chemical reaction). Instead I made the decision to
ignore it, and suffered the consequences.

Now, I could take responsibility for my own stupidity in ignoring the
warnings and just assuming that there would be no side-effects.

Or I could stamp my feet and holler at the top of my voice that it is the
petrol seller's fault, and that he should have locked this special fuel
away and banned everyone else from using it, to protect idiots like myself
from shooting myself in the foot. (Or setting my car on fire, as the case
may be.)

After all, while I made a free choice to use the private petrol, despite
all the warnings and all the reasons why I should not, it certainly
shouldn't be my responsibility to deal with the consequences of my own

>> The engineering decisions regarding my application should be on my
>> side, not the language lawyers.
> No problem, but any decision like that should be expressed in
> "writing", by re-declaring the variable so it's no longer private.

How do you see this working in practice?

Say you have written a class, with a private variable. I decide that I
need access to that variable, for reasons you never foresaw. What happens
next? I ask you nicely to please change your class and turn that private
attribute into a public one. What happens if you refuse? Can I have you
taken out and shot and seize ownership of your class, or do I have to
copy and paste your class into my code, creating a duplicate class I can
modify as much as I like?


More information about the Python-list mailing list