encapsulation?

brueckd at tbye.com brueckd at tbye.com
Tue Aug 7 21:09:24 EDT 2001


On Tue, 7 Aug 2001, Lloyd Goldwasser wrote:

> liability.  It would seem to make Python ineligible for use in projects
> that need a more reliable separation between objects and outside
> access.  How hard (or desirable) would it be to provide a stronger kind
> of encapsulation in Python?

You can control access any way you want. Implement your own __getattr__
and __setattr__ functions kind of like the Bastion module does (read
through the source code as it has some good comments on doing what you
want).

You might even be able to implement it as a mixin class so that you
could add encapsulation to pre-existing classes.

-Dave





More information about the Python-list mailing list