To make a method or attribute private

Chris Angelico rosuav at gmail.com
Sun Jan 20 20:26:18 EST 2013


On Mon, Jan 21, 2013 at 12:14 PM, iMath <redstone-cold at 163.com> wrote:
> so there is no REAL private variable in Python but conversion exists in it that python programmer should follow and recognize .right ?

That's about it. If you think about C++ public members as the
"interface" and private/protected members as the "implementation",
then Python's convention is a leading underscore on the latter; you
can reasonably expect that non-underscore members can be trusted to be
maintained, but underscored members will quite possibly change in
subsequent versions.

Among smart people, conventions like this are all you need.

ChrisA



More information about the Python-list mailing list