Using Python I want to create a property in a class, but having its name in a string. Usually you do:
blah = property(get_blah, set_blah, del_blah, "bleh blih")
where get_, set_, and del_blah are defined respectively. I tried to do the same with the property name in a variable, like this:
setattr(self, "blah", property(self.get_blah, self.set_blah, self.del_blah, "bleh blih"))
But that does not work. The first case blah returns the value of the property, in the second case it returns the property, that is <property object at 0xbb1aa0>. How can I define it so that it works?
source
share