Encapsulation unpythonic?

Roy Smith roy at panix.com
Sun Sep 1 18:02:50 EDT 2013


In article <mailman.461.1378072496.19984.python-list at python.org>,
 Tim Delaney <timothy.c.delaney at gmail.com> wrote:

> On 2 September 2013 06:33, Ethan Furman <ethan at stoneleaf.us> wrote:
> 
> >
> > class PlainPython:
> >
> >     value = None
> >
> >
> > In the Javaesque class we see the unPythonic way of using getters/setters;
> > in the ProtectedPython* class we see the pythonic way of providing
> > getters/setters**; in the PlainPython class we have the standard,
> > unprotected, direct access to the class attribute.
> >
> > No where in PlainPython is a getter/setter defined, nor does Python define
> > one for us behind our backs.
> >
> > If you have evidence to the contrary I'd like to see it.
> >
> 
> I think Roy is referring to the fact that attribute access is implemented
> via __getattr__ / __getattribute__ / __setattr__ / __delattr__. From one
> point of view, he's absolutely correct - nearly all attributes are accessed
> via getters/setters in Python.
> 
> Tim Delaney

Thank you.



More information about the Python-list mailing list