Will python never intend to support private, protected and public?

Paul Rubin http
Sat Oct 1 09:28:27 CEST 2005

Mike Meyer <mwm at mired.org> writes:
> Unless your compiler detects and flags passing private variables to
> external functions all you've got is a convention that you don't pass
> private variables to external functions.

Yes, the point is that it's something that you can check for by
examining the class in question without having to examine any other

> Are you going to try and tell me thas using builtin functions on
> private variables is something you don't allow in your projects?

You have to treat builtin functions as part of the language.  Of
course Python has this situation where someone could rebind the name
"len" to some other function, so you have to deal with that too, maybe
just at the file scope.  An OOP approach (lst.len() instead of
len(lst)) that binds the builtin names to datatypes might be
preferable in some situations but I'll leave that one for the

> Of course, there's nothing wrong with catching errors earlier. Might I
> suggest that you file a change request for pylint (or your favorite
> error checker) asking that it start issuing warnings for
> object._variable?

I don't see how pylint could know which instances to flag, without
doing type inference on all the objects to know that the variable
belonged to an instance of some other class.

More information about the Python-list mailing list