Encapsulation unpythonic?

Joshua Landau joshua at landau.ws
Sun Aug 18 13:15:10 EDT 2013


On 17 August 2013 17:17, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Sat, 17 Aug 2013 05:26:32 -0700, fsaldan1 wrote:
>> how do I
>> deal with the fact that other programmers can easily alter the values of
>> members of my classes?
> ...
> If they insist on messing with your private single-underscore
> _attributes, you can't stop them, but that's okay, you don't have to be
> sympathetic when they shoot their foot off. Just slap them with a large
> halibut[1] and laugh.

I know I've cropped your points but I just want to mention here that
the only reason to monkey-patch code in these ways where you'd want to
stop them is when the alternative is *worse*. It's like removing railings from
a cliff to stop people hitting the bars.



More information about the Python-list mailing list