Entry
Can I implement access control in my classes (equivalent to C++'s private, public, protected, etc...)?
Sep 2nd, 2000 02:29
unknown unknown, Alex Martelli
Naming an item with two leading underscores (and without two
_trailing_ underscores as well) is as close to "private" as Python
comes (the compiler decorates the attribute name with the
classname, so no accidental clash is possible any more). There
is, AFAIK, no parallel to "protected" (nor any particular need for
it; it is, after all, a feature which Stroustrup deeply regrets
having let himself be talked intro introducing in C++ -- see his
excellent book "Design & Evolution of the C++ Programming
Language").