[bind10-dev] Python classes vs modules vs other funny stuff

Stephane Bortzmeyer bortzmeyer at nic.fr
Mon Oct 12 14:33:40 UTC 2009


On Mon, Oct 12, 2009 at 09:22:27AM -0500,
 Michael Graff <mgraff at isc.org> wrote 
 a message of 23 lines which said:

> I do not know how to do this in Python.  Can someone shed some light on  
> this?

Isn't it simply a class method? If so, just use the decorator
"classmethod":

class Klass:

    # This is called a decorator
    @classmethod
    def klass_method(self, foo, bar):
        # Ignore self
        return (42 + len(foo) + len(bar))


if __name__ == '__main__':
    # No object (no instance of Klass) created
    print Klass.klass_method("isc", "bind")
    



More information about the bind10-dev mailing list