Python: How to replace a property with a regular attribute?

The base class has the following:

def _management_form(self):
    # code here
    return form
management_form = property(_management_form)

In my derived class, I am trying to write this:

self.management_form = self.myfunc()

But of course this will not work. He tells me that "it is not possible to set an attribute" because this property does not have a setter. But I do not want to install it, I want to redefine what "managent_form" means. I set del self.managent_formit first , but that didn't work either. So how do I fail?

+5
source share
1 answer

You can assign a class instead of an instance:

MyClass.management_form = property(self.myfunc)

, ( ). , , ( , , ).

:

class MyOtherClass(MyClass):
    def _new_mf(self):
        # Better code
        return form
    management_form = property(new_mf)
+6

All Articles