Protected Methods and Python

Mads Orbesen Troest mads at troest.NEVERMORE.dk
Sun Apr 13 15:24:24 EDT 2003


On 13 Apr 2003 11:58:36 -0700, srijit at yahoo.com wrote:

> Or may be it is possible to emulated Protected Methods in Python.

It can be "emulated" by prepending the method/attribute name with 2 
underscores. This will make Python mangle the name so noone accidentally 
can access it. Evil minds can still do whatever they want, but then again - 
it's their own responsibility if they break things then. ;)

I also feel it's weird that Python doesn't have a truly enforced 
encapsulation scheme, but one can live with it.

HTH,
/\/\\ads Orbesen Troest




More information about the Python-list mailing list