Class design: accessing "private" members
Frédéric van der Plancke
fplancke at my-deja.com
Mon Jul 3 14:59:02 EDT 2000
In article <8jplbd0l5c at news2.newsguy.com>,
"Alex Martelli" <alex at magenta.com> wrote:
> Such "prohibition" is not hard at all:
>
> class dontderive:
> def __init__(self):
> if self.__class__ != dontderive:
> raise "told you not to!"
>
> class foo(dontderive):
> pass
>
#but...
class bypassing_prohibition(dontderive):
def __init__(self):
pass
eh = bypassing_prohibition()
#this works because __init__ never automatically calls the __init__
#method of base classes...
--
Frederic van der Plancke
e-mail address: reverse and add dot-at-dot to:
<com writeme vdplancke frederic>
(I don't read <fplancke at my-deja.com> regularly.)
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list