Does anyone know of a way to change a property from read-only to writable on the fly without changing the source?

>>> p = property(lambda self: self.__p)
>>> p.fset = lambda self: self.__p
Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    p.fset = lambda self: self.__p
TypeError: readonly attribute

Well, I can't think of a way, other than:

>>> p = property(lambda self: self.__p)
>>> p = property(lambda self: 10)  #reassigning p to a new property

I think its actually read-only, maybe with no ways to work around it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.