Encapsulation unpythonic?

Ethan Furman ethan at stoneleaf.us
Sun Sep 1 20:24:34 EDT 2013


On 09/01/2013 02:54 PM, Tim Delaney wrote:
> Roy Smith wrote:
>>
>> Nothing is accessible in Python except via getters and setters.  The
>> only difference between Python and, say, C++ in this regard is that the
>> Python compiler writes them for you most of the time and doesn't make
>> you put ()'s at the end of the name
>
> 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.

Seems to me there is a difference between an underlying generic protocol for data manipulation and "Python writing them 
[getters/setters] for you".

--
~Ethan~



More information about the Python-list mailing list