Re: Underscore data hiding (was python development practices?)
by John Roth other posts by this author
Nov 1 2001 4:58AM messages near this date
Re: Underscore data hiding (was python development practices?)
|
Re: python development practices?
"Skip Montanaro" <skip@[...].com> wrote in message
news:mailman.1004551677.1783.python-list@[...]..
>
> 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.
It also 'hides' the names from a 'from <module> import *' construct.
> --
> Skip Montanaro (skip@pobox.com)
> http://www.mojam.com/
> http://www.musi-cal.com/
>
--
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
|