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

Luis Zarrabeitia kyrie at uh.cu
Wed Jan 14 11:00:50 EST 2009


On Tuesday 13 January 2009 10:32:54 pm James Mills wrote:
> Should Python get strict and enforce access control
> of object members ? No. Why ? I can think of several
> reasons.
>
> Give me one use-case where you strictly require
> that members of an object be private and their
> access enforced as such ?

Devil's advocate here - I think I can give you one:

when you need to share some objects with potentially untrusted code (like, a 
plugin system). You can't, and you shouldn't, expect that the user will know 
what plugins he should or shouldn't load, and you shouldn't blame him/her 
when your app stops working because you failed to protect it's internals from 
malicious plugins (think web browser).

Of course... in that scenario, the public/private distinction is the least of 
the concerns... and whatever is done to solve them will likely make 
irrelevant if the members are private or public.

But, for trusted code? Or at least code known at compile time? It's just not 
worth it... pylint should take care of that - and if it doesn't, the OP 
should go fix it.

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie



More information about the Python-list mailing list