Search code examples
pythonpython-3.xstatic-methods

the design of a class consisting of a set of @statisticmethod functions


While reading a python project, I found the author wrote a lot of classes with the following manner, i.e., a given class only consists of a set of functions of @statisticmethod, such as class readingUtils in the following. My question is that does this design belong to a specific type of design pattern, or does it have any specific design consideration?

class readingUtils(object):

    @staticmethod
    def function1(var1, var2):
        ----
    
    @staticmethod
    def function2(var1, var2):
        -----

Solution

  • That's just a variant of the "singleton" pattern. It's just a way of collecting functions into a coherent group, without having any shared state.