To make a method or attribute private

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jan 21 04:27:37 CET 2013


On Sun, 20 Jan 2013 17:14:36 -0800, iMath wrote:

[...]
> so there is no REAL private variable in Python but conversion exists in
> it that python programmer should follow and recognize .right ?

There are no "REAL private variables" in most languages. Consider the C++ 
trick "#define private public". Or pointer tricks, or using reflection in 
Java.

Yes, the convention in Python is that names starting with a single 
underscore should be considered private implementation details.



-- 
Steven



More information about the Python-list mailing list