Writing a read only attribute

Michele Simionato michele.simionato at gmail.com
Fri Jul 6 09:48:13 CEST 2007

On Jul 6, 8:27 am, Fabrizio Pollastri <pollas... at iriti.cnr.it> wrote:
> Hello,
> it is possible to force in some way a write to a read-only attribute of
> a python object?  In which case?
> Thanks for any answer.
> F. Pollastri

What do you mean by read-only attribute?
If you are trying to change attributes of built-in objects, there is
no hope:

>>> 'astring'.upper = 2

AttributeError: 'str' object attribute 'upper' is read-only

If the read-only attribute has been implemented via a property, there
is a way
to write it, but you should tell us more about your case.

        Michele Simionato

More information about the Python-list mailing list