Will python never intend to support private, protected and public?
Thu Sep 29 01:36:03 CEST 2005
Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> No, but that is precisely why Python's semi-private variables are
> usually better. Names like _X and class.__X are warnings to the developer
> "use these at your own risk", without preventing developers who need them
> from using them. You have most of the benefits of private variables with
> none of the disadvantages.
I'm sorry but I thought the idea was to actually reduce the risk of
bugs, not merely attach the risk to the right person. If changing the
way a class uses its own private variables breaks an application
because another class was using the private variable unexpectedly,
then that's bad, regardless of whether the other class's author was
notified or not. It's better to let the compiler automatically flag
these things, than to depend on conventions.
More information about the Python-list