Calling private base methods

Maric Michaud maric at aristote.info
Thu Apr 12 09:24:13 EDT 2007


Le jeudi 12 avril 2007 10:47, Jorgen Bodde a écrit :
>  I thought I understood
> how super() worked, but with 'private' members it does not seem to
> work.
 I would add to what is already said, that you should just forget the 
private -public - protected concepts in Python.

There is no access control to members in Python, but :

- names not beginning by an underscore belong to the API of a class (C++ 
public) or module, whether they are methods or properties.
- names beginning by a single underscore are used internally by a class or a 
module, the caller should not use/import them at all.
- names enclosed by double underscore are parts of the language semantic, 
don't define yours.

All these are conventions.
Finally :

- names beginning by double underscore are mangled at class creation time, 
they should be used only to avoid name collision in subclasses (practically 
this is rarely needed).

Python is alot about conventions, please read and follow the PEP 8 : 
http://www.python.org/dev/peps/pep-0008/

-- 
_____________

Maric Michaud




More information about the Python-list mailing list