Why I use private variables (WAS: RE:"private" variables a.k.a. name mangling?)
steven.bethard at gmail.com
Mon Jan 24 17:52:47 EST 2005
Philippe C. Martin wrote:
> 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.
> 2) Must not be documented to library users as they're using it would
> go againts 'law' 1).
Yeah, I use single-underscores for similar reasons, and so that
PythonWin doesn't show my "private" variables in the drop-down list of
object attributes. I think for most uses, no name-mangling is required...
Of course, I could generate an arbitrary number of "problem cases" -- I
just don't think they happen often in real code...
More information about the Python-list