# implementation of classmethod and staticmethod, equivalent to the standard library

class

MyClassmethod

:

def

__init__

(

self

,

func

):

self

.

func

=

func

# ignore the instance, provide the class as first argument (usually named cls) so the

# returned function can be called with the arguments the user wants to explicitly provide

def

__get__

(

self

,

instance

,

owner

):

def

cls_wrapper

(

*

args

,

**

kwargs

):

return

self

.

func

(

owner

,

*

args

,

**

kwargs

)

# what if I put cls=owner?

return

cls_wrapper

class

MyStaticmethod

:

def

__init__

(

self

,

func

):

self

.

func

=

func

# essentially just accepts a function and then returns it when __get__ is called

def

__get__

(

self

,

instance

,

owner

):

return

self

.

func