Why I use private variables (WAS: RE:"private" variables a.k.a. name mangling?)

Philippe C. Martin philippe at philippecmartin.com
Mon Jan 24 23:30:38 CET 2005

I used double underscore because I thought it was the correct way to name
private variables/methods - I will have to change those to single
underscore since that it the current methodology.

A private variable to me:
1) is internal to the processing of a class and needs not be accessed by
external or derivated objects. (I won't get into the
potential need of "protected" variables/methods - Python creators have not
made those distinctions for reasons that they believe are good and I'm not
the one to discuss them)
2) Must not be documented to library users as they're using it would
go againts 'law' 1).
3) I wish I had one, but there is only one Isaac Asimov after all :-)



On Mon, 24 Jan 2005 11:45:34 -0500, Jeremy Bowers wrote:

> On Mon, 24 Jan 2005 15:35:11 -0600, Philippe C. Martin wrote:
>> The real reason behind my using private variables is so they do not appear
>> in the epydoc generated documentation and confuse my users.
> You mean single or double underscores? I just checked and at least epydoc
> 2.1 doesn't include single-underscore values, but those aren't "private"
> in sense we're talking in this thread (some form of compiler enforcement).

More information about the Python-list mailing list