How can I make an existing object read-only?

Alex Martelli aleaxit at
Tue Oct 5 08:04:31 CEST 2004

Irmen de Jong <irmen at> 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'.


More information about the Python-list mailing list