making objects unassignable "read-only" (especially when extending)
Fredrik Lundh
fredrik at pythonware.com
Wed Jan 18 11:00:43 EST 2006
Johannes Zellner wrote:
> can I make an object read-only, so that
>
> x = new_value
>
> fails (and x keeps it's orginal value)?
the original x does contain the original value; assignment only changes
the binding in the target namespace. you cannot override this.
you can control attribute assignment, though:
x.y = new_value
(via __setattr__ methods/slots on the x object)
</F>
More information about the Python-list
mailing list