[Tutor] Implementing data hiding in Python

Arthur Watts arthur.watts@gbst.com
Wed, 12 Jul 2000 11:56:05 +1000


Guys,

	I don't want to get into religious wars re the benefits of
encapsulation and the use of 'private', 'const' or whatever. I know that I
can use 'name-mangling' via '__foo' from Python 1.5 to give me a limited
form of privacy and I have seen allusions to extensions that enforce data
hiding :

There is little direct support for data hiding within Python itself, but
extensions and embeddings of Python can provide rock solid interfaces that
expose only permitted foreign operations to the Python interpreter. Python's
restricted execution mode may also provide some (usually extreme) protection
within the interpreter itself.             

	I need to know if anyone has written said extensions, as I am unable
to find anything at the Vaults of Parnassus archive. I suspect that the
above quote may indicate that we need to write our own extensions to enforce
data-hiding on a class-by-class basis, but I'm open to suggestions. The
issue is *not* coding to prevent breaking modules by trampling one anothers
namespaces, it is convincing management that Python is the right tool for
the bulk of the project. 

Thanks,

Arthur 

Arthur Watts
Systems Integrator
GBST Pty Ltd

'Good programmers know what to use, great programmers know what to re-use' :
Old Jungle Saying