About the use of **args

Peter Hansen peter at engcorp.com
Wed Dec 10 09:30:13 EST 2003


Jacek Generowicz wrote:
> 
> Duncan Booth <duncan at NOSPAMrcp.co.uk> writes:
> 
> > Mark McEahern <marklists at mceahern.com> wrote in
> > news:mailman.27.1071059861.9307.python-list at python.org:
> >
> > > # We can still access the "private" member variable.  In Python,
> > > # private is merely a convention.
> > > print s._size
> >
> > Except that in Python the convention for private variables is to begin them
> > with two underscore characters, and then it is more than just a convention:
> 
> Now, I always believed that "private" in Python is spelt "_", while
> "mangle this name for me because I want to avoid name clashes in
> multiple inheritance scenarios" is spelt "__".
> 
> However, I've heard _so_ many people make the (in my opinion
> incorrect) claim that "private" is spelt "__", that I'm beginning to
> question my sanity.

Distinguish "private" and "protected", as in C++ and perhaps wider usage.

"private" is spelled __ in Python and is supported in a limited fashion
by the language, while *protected* is spelled _ and is by convention.

-Peter




More information about the Python-list mailing list