New PEP: Attribute Access Handlers
Paul Prescod
paul at prescod.net
Sun Jul 23 02:33:59 EDT 2000
Robin Becker wrote:
>
> ...
> If the attr is a mutable sequence/map etc how can they be made readonly
> using this scheme, are we forced to make immutable string types etc
There are two different things. One is stopping the attr from being
re-bound. That's what the PEP allows. The other is stopping the attr
*value* from being mutated. That depends on the design of the attr
value.
I guess the PEP could help (a little) with that too.
def __get_foo__(self, op, val ):
return ReadOnlyProxy( self.__foo )
--
Paul Prescod - Not encumbered by corporate consensus
New from Computer Associates: "Software that can 'think', sold by
marketers who choose not to."
More information about the Python-list
mailing list