Methods for Both Classes and Instances in Python

0.00 avg. rating (0% score) - 0 votes

I came across a situation where it would be nice for a Python class to have a method which works for both the class and its instances, and when called in an instance context, to know on which instance it was invoked. Python does not support this directly, but as it is a very flexible language, it can be done. To make it work somewhat nicely requires just a few lines of not so obvious code.

Continue reading Methods for Both Classes and Instances in Python