Re: making objects unassignable "read-only" (especially when extending)

2006-01-18 Thread Fredrik Lundh
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 as

Re: making objects unassignable "read-only" (especially when extending)

2006-01-18 Thread Rocco Moretti
Johannes Zellner wrote: > Hi, > > can I make an object read-only, so that > > x = new_value > > fails (and x keeps it's orginal value)? Simon gave you a way of doing it when x is an attribute access (e.g. p.x). I am unaware of a way of doing it when x is a straight global or local. Unlike

Re: making objects unassignable "read-only" (especially when extending)

2006-01-18 Thread Simon Brunning
On 18 Jan 2006 11:59:23 GMT, Johannes Zellner <[EMAIL PROTECTED]> wrote: > Hi, > > can I make an object read-only, so that > > x = new_value > > fails (and x keeps it's orginal value)? This works for me: http://groups.google.com/group/comp.lang.python/msg/2b1785397358ff90 -- Cheers, Simon B,

making objects unassignable "read-only" (especially when extending)

2006-01-18 Thread Johannes Zellner
Hi, can I make an object read-only, so that x = new_value fails (and x keeps it's orginal value)? This would be especially of interest for me for an object created by a c extension. -- Johannes -- http://mail.python.org/mailman/listinfo/python-list