Will python never intend to support private, protected and public?
apardon at forel.vub.ac.be
Fri Sep 30 09:11:03 CEST 2005
Op 2005-09-29, Rocco Moretti schreef <roccomoretti at hotpop.com>:
> en.karpachov at ospaz.ru wrote:
>> On Fri, 30 Sep 2005 00:16:02 +1000
>> Steven D'Aprano wrote:
>>>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 if the access to that variable was forbidden for reasons you never
>> foresaw? What if the class author decide to remove the variable in the next
>> version of the class, because it's not an interface, but only a part of the
>> class implementation?
> What if the class author removes a non-private variable or changes a
> method's documented parameters in the next version of the class, because
> he think it'll work better, or just because he can?
Changing an interface is different from changing the implementation.
A (documented) interface is like a contract. The implementation is
just one way to follow that contract.
> People who think that forbidding access to private variables/methods
> will save themselves from upgrade woes are deluding themselves.
It helps, just as locks wont save you from burglars if they really
want to rob you, but the locks do help.
More information about the Python-list