private

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Sat Jun 29 13:35:02 EDT 2002


Rhymes <rhymes at myself.com> writes:
> Is there any possibility to build up a _real_ private attribute?
> Such as C++ private data members...
> I know that with double-underscore prefix (and the name mangling related)
> I can " hide " data members but I think it's not a so crafty trick...
> Is there any PEP about it? Will Guido insert a private keyword
> in a future release of Python ?

Well, as several people have said, C++ private members aren't that
private either.  If you mean something like private members in Java
which try to really enforce privacy against hostile callers, no,
there's nothing like that in Python.  The only way to simulate it is
with a remote object scheme, putting the protected objects in a
separate process (or separate computer) from the caller, and letting
them run their own access policy.  This has more overhead than
ordinary method calls, but can be made very secure.




More information about the Python-list mailing list