2021年4月28日星期三

What is the best practice to give a namespace for a bunch of static methods?

I need a namespace within a module for many different static methods doing similar jobs. From my research I learnt that having a class full of static methods is considered anti-pattern in Python programming:

class StatisticsBundle:    @staticmethod    def do_statistics1(params):       pass      @staticmethod    def do_statistics2(params):       pass  

If this isn't a good solution, what is the best practice instead that allows me to do a namespace lookup like getattr(SomeNameSpace, func_name) within the same module?

https://stackoverflow.com/questions/67254666/what-is-the-best-practice-to-give-a-namespace-for-a-bunch-of-static-methods April 25, 2021 at 10:52PM

没有评论:

发表评论