Will python never intend to support private, protected and public?

Paul Rubin http
Wed Sep 28 19:36:03 EDT 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 mailing list