Difference between staticmethod and classmethod

后端 未结 28 2199
一整个雨季
一整个雨季 2020-11-21 06:11

What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?

28条回答
  •  自闭症患者
    2020-11-21 06:48

    @classmethod : can be used to create a shared global access to all the instances created of that class..... like updating a record by multiple users.... I particulary found it use ful when creating singletons as well..:)

    @static method: has nothing to do with the class or instance being associated with ...but for readability can use static method

提交回复
热议问题