Python overriding getter without setter

Use just the .getter decorator of the original property: class superhuman(human): @human.name.getter def name(self): return ‘super ‘ + self._name Note that you have to use the full name to reach the original property descriptor on the parent class. Demonstration: >>> class superhuman(human): … @human.name.getter … def name(self): … return ‘super ‘ + self._name … >>> … Read more

What is the right way to override a setter method in Ruby on Rails?

=========================================================================== Update: July 19, 2017 Now the Rails documentation is also suggesting to use super like this: class Model < ActiveRecord::Base def attribute_name=(value) # custom actions ### super(value) end end =========================================================================== Original Answer If you want to override the setter methods for columns of a table while accessing through models, this is the way to … Read more

Setter methods or constructors

You should use the constructor approach, when you want to create a new instance of the object, with the values already populated(a ready to use object with value populated). This way you need not explicitly call the setter methods for each field in the object to populate them. You set the value using a setter … Read more