Re: Underscore data hiding (was python development practices?)
by Peter Wang other posts by this author
Oct 31 2001 10:59PM messages near this date
Re: python development practices?
|
Re: Underscore data hiding (was python development practices?)
On Wed, 31 Oct 2001 12:05:11 -0600, Skip Montanaro <skip@[...].com>
wrote:
>
> Russell> My understanding is that a double underscore is required for
> Russell> Python to automagically mangle the name. On the other hand, two
> Russell> postings now suggest that a single underscore is sufficient.
>
> Russell> If double underscore is required, then it seems to me this is a
> Russell> very common misconception that a single is sufficient. It might
> Russell> be worth changing.
>
> A double leading underscore is requred to coax Python into mangling an
> attribute. I think a lot of people use a single underscore as a simple cue
> for themselves and other programmers that an attribute isn't meant to be
> part of the public interface without messing up the actual name, so it can
> be used easily in subclasses.
heh... so:
C++::private == Python."__*"
C++::protected == Python."_[a-zA-Z]*"
C++::public == Python."[a-zA-Z]*"
;)
-peter
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Peter Wang
Peter Hansen
Toby Dickenson
Tim Peters
Steve Holden
Steve Holden
Cliff Wells
Tim Peters
Martijn Faassen
Cliff Wells
Cliff Wells
Martijn Faassen
Martijn Faassen
Paul Rubin
Russell E. Owen
Barry A. Warsaw
Martijn Faassen
Peter Wang
Skip Montanaro
John Roth
David Bolen
Peter Wang
Peter Wang
Skip Montanaro
Chris Tavares
Darren Collins
David Bolen
Paul Rubin
Paul Rubin
Peter Wang
F Basegmez
Richard Jones
Richard Jones
Neal Norwitz
Graham Ashton
Peter Wang
Russell E. Owen
Skip Montanaro
Cliff Wells
Hung Jung Lu
Wade Leftwich
Peter Wang
Peter Wang
Peter Wang
Chris Gonnerman
Paul Rubin
Andrew Dalke
Paul Rubin
Luigi Ballabio
Paul Rubin
Tim Peters
John Roth
Paul Rubin
Richard Jones
|