How can I make an existing object read-only?
Alex Martelli
aleaxit at yahoo.com
Tue Oct 5 02:04:31 EDT 2004
Irmen de Jong <irmen at -nospam-remove-this-xs4all.nl> wrote:
...
> > def __setattr__(self, n, *args): raise AttributeError, n
> > __delattr__ = __setattr__
...
> Incidentally, why are you writing:
>
> def __setattr__(self, n, *args): ...
>
> with a varg list ? I always assumed it only got a single 'value' parameter?
Just to be able to reuse the same method as __delattr__ in the very next
line; could have coded 'v=None', say, equivalently to '*args'.
Alex
More information about the Python-list
mailing list