I coined the term, bimorphic method, last week. Shortly after I wrote about them, I found I wanted a bimorphic property too. It’s the same idea: create a decorator that turns a method into a property getter for both the class object and instances of the class. Here’s an example.
Posts Tagged ‘python’
Posted by kernelbob on June 26, 2008
Posted by kernelbob on June 15, 2008
Methods in Python are either instance methods (the default), static, or class methods. You can create the latter two using the @staticmethod and @classmethod decorators.
But maybe it would be better to have a single function that can be called either as a class method or an instance method. I coined the term bimorphic method for this, and I wrote a decorator that can make a method bimorphic.