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

Rhamphoryncus rhamph at gmail.com
Tue Jan 20 15:18:09 EST 2009


On Jan 20, 12:04 pm, "Russ P." <Russ.Paie... at gmail.com> wrote:
 Hey, if pylint can reliably detect private data access violations,
> that's good news to me. I haven't used it, so I don't know. (I used
> pychecker a while back, but I haven't used that for a while either.)
>
> If pylint can check access violations, then it seems to me that
> someone (who is familiar with the internals of the Python interpreter)
> should be able to integrate that feature into Python itself relatively
> easily.
>
> Actually, in addition to the enforcement of "private," you also need
> the enforcement of "protected." If you only enforce "private," derived
> classes will not have access to data they need. And if you don't
> enforce "protected," then anyone can trivially gain access to private
> data by simply deriving a new class. It would be like having a lock on
> the door with the key hanging right there on a string.
>
> I realize that this complicates matters. As I said before, I am not
> claiming that Python should necessarily get enforced data hiding. All
> I am saying is that, if it doesn't get it, it will never be
> appropriate for certain domains. But maybe nobody cares about that
> except me.

If pylint had "private" it should behave like "protected".  Basic
encapsulation is about good style (separation of concerns), not
security, and subclassing is a clear statement that this concern is
closely related.

Of course if you accept that the extremism of security is a separate
issue then you have the question of how much is necessary to encourage
separation of concerns, and and what should be available to work
around it...


> The other problem with the pylint approach is aesthetic: the
> requirement for a leading underscore to indicate private data. I
> realize that some actually like that convention, but I don't. I spend
> most of my development time working with "private" data, and why
> should I have to look at that litter everywhere? I use Python in part
> because I want clean looking code, and leading underscores bother me
> -- just as the leading dollar signs in Perl bother many Python
> programmers.

There needs to be *some* indicator that separates a public property
from a private one.  What would you suggest?



More information about the Python-list mailing list