1. 2009
    Jul
    27

    More Python voodoo: combination class/instance methods

    Here’s a neat tidbit from my website code: Let’s say you’re writing a class, and you want it to have some methods that can be called as either class or instance methods. Of course, you can do it by writing a class method, but if you want the method to be able to use instance attributes when it’s called on an instance, you can do it using a descriptor. Here’s how.