privacy in Python
Fredrik Aronsson
d98aron at dtek.chalmers.se
Wed Aug 29 10:34:01 EDT 2001
In article <39ce62b8.0108290610.42e6a3b0 at posting.google.com>,
ens_z at yahoo.com (Ens) writes:
> class cls:
> def f(self, a, b):
> print a+b
> __p=12
>
> obj=cls()
> fun=obj.f
> print fun.im_self._cls__p
>
> 12
>
> I need that '__p' exactly be private.
--
You mean private as in cannot be accessed outside the class?
In that case I don't think it's possible.
(I don't thinks it is even possible in c++... you can always get the variable
by raw access to memory if needed)
/Fredrik
More information about the Python-list
mailing list