Function defined outside the class : Class Method « Class « Python






Function defined outside the class

 


def f1(self, x, y):
    return min(x, x+y)

class C:
    f = f1
    def g(self):
        return 'hello world'
    h = g

a = C
a.g

           
         
  








Related examples in the same category

1.Define function to change member dataDefine function to change member data
2.Class method Demo: define and callClass method Demo: define and call
3.Getter and Setter Methods
4.roman Number