About the use of **args
Jacek Generowicz
jacek.generowicz at cern.ch
Wed Dec 10 08:38:38 EST 2003
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.
Where is the Python spelling of "private" set in stone ?
I find the suggestion that a mangled name is somehow "more private"
than one with a single leading underscore, mildly insulting to the
clients of your code. The implcation is that they can neither work out
the (very complicated and cryptic[*]) mangling scheme, not use dir().
If a Python programmer wants to acces a private attribute, he can do
so, regardless of the number of leading underscores.
[*] Sarcasm alert. (This alert was brought to you by the International
Campaign for Promotion of Understanding between Cultures.)
More information about the Python-list
mailing list