Does Python really follow its philosophy of "Readability counts"?

Luis Zarrabeitia kyrie at uh.cu
Mon Jan 19 20:09:40 EST 2009


Quoting "Russ P." <Russ.Paielli at gmail.com>:

> On Jan 19, 7:13 am, Bruno Desthuilliers <bruno.
> 42.desthuilli... at websiteburo.invalid> wrote:
> 
> > I must be missing the point : if it's a public attribute, it doesn't
> > need a "property" ? I guess we use the same words for different things
> here.
> 
> Yes, you are missing more than one point.
> 
> Scala automatically converts public data members into properties,
> apparently to save the programmer the trouble of doing it manually. If
> you are interested, I'm sure you can find publicly available
> information on it.

Russ, I think _you_ are missing the point.
If the attribute is already public, why does it need properties? Why would a
programmer go to the trouble of adding them manually, just to get one level of
indirection for an already public attribute?

> > I definitively wouldn't bet my ass on language-level access restriction
> > to protect software from fraud or sabotage.
> 
> You're missing the point here too. I'll try one more time to explain
> it.

And I think you are conflating the idea of "private" as in "secret information
that should not be known by the _public_" and "private" as in "static safeguards
enforced by the compiler to prevent accidents" [and you are missing the third,
"compiler feature to prevent namespace pollution without having to use extremely
unlikely variable names", i.e, self.__x in python].

No wonder you can't get Bruno's point. For the second, static checks to prevent
accidents, you have pylint. For the first, not only you are using the wrong
tool, but you are barking at python for not having it. Assuming that pylint is
perfect (big assumption, but it is up to you to prove where it fails), what
would be the difference between only accepting/running "pylint-authorized code"
and the enforced hiding you desire?

This thread is starting to remind me of a professor of mine, who once claimed
that python didn't have private attributes because it "is opensource and anyone
can see the source code anyway", and the obvious confusion of his students ("why
should I make my entrypoint '_public_ static void main', if it is _my_
sourcecode and I don't want to share it?").

What you want is not enforced data hiding. You want something actually designed
to try to prevent abuses from hostile programmers - go use .Net or Java, who
attempt to do that (I don't know with what level of success, but they at least
provide you the 'locks' and 'police' that you need). Or better yet, write a
proposal about how to implement code trust in Python. I'll support you on that
one, and I think many others will. But if you keep presenting data hiding as a
solution to that problem... I doubt that you will be heard.

-- 
Luis Zarrabeitia
Facultad de Matemática y Computación, UH
http://profesores.matcom.uh.cu/~kyrie





More information about the Python-list mailing list