Re: Underscore data hiding (was python development practices?)
by Toby Dickenson other posts by this author
Nov 5 2001 12:35PM messages near this date
Re: Underscore data hiding (was python development practices?)
|
RE: Underscore data hiding (was python development practices?)
barry@[...].com (Barry A. Warsaw) wrote:
> FWIW, the double-leading-underscore-no-trailing-double-underscore name
> mangling rule wasn't added specifically for data hiding. It was so
> that a class that was designed to be subclassed could have a namespace
> that subclasses couldn't accidently trample on:
Interestingly, I often find that that the chosen mangling scheme
doesnt achieve that design goal. The scheme mangles the class name
into the underscore-stripped attribute name, which offers zero
protection if your base classes and subclasses have the same name.
Does this happen often? A common structure (for me, anyway) is to have
modules BaseWidget, FooWidget, and BarWidget, all of which define a
class Widget.
Toby Dickenson
tdickenson@[...].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
|