How to use static method in class with Python

2 Answers

0 votes
class Worker:
    name = ""

    def __init__(self, name):
        self.name = name

    def show(self):
        print("the name is: " + self.name)

    @staticmethod
    def static_method():
        print("static_method")

tom = Worker("Tom")
tom.static_method()

 
'''
run:
 
static_method
 
'''

 



answered Jun 20, 2018 by avibootz
0 votes
class Worker:
    name = ""

    def __init__(self, name):
        self.name = name

    def show(self):
        print("the name is: " + self.name)

    @staticmethod
    def static_method():
        print("static_method")

Worker.static_method()


'''
run:
 
static_method
 
'''

 



answered Jun 20, 2018 by avibootz

Related questions

1 answer 189 views
1 answer 194 views
1 answer 177 views
2 answers 242 views
1 answer 201 views
...