Encapsulation unpythonic?
Tim Delaney
timothy.c.delaney at gmail.com
Sun Sep 1 17:54:53 EDT 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130902/f9d5a5cb/attachment.html>
More information about the Python-list
mailing list