Python 在uuu init_uuu调用的方法:使其功能化(因此是静态方法)或非功能化(以及标准方法)

Python 在uuu init_uuu调用的方法:使其功能化(因此是静态方法)或非功能化(以及标准方法),python,class,static-methods,Python,Class,Static Methods,我对决定以下两种设计类型的标准感兴趣: 我现在是如何简化的: class CommentThread(object): def __init__(self, url): self.req = requests.get(url) self.soup = BeautifulSoup(self.req) self.graph = self.parse_thread(self.soup) @staticmethod def par

我对决定以下两种设计类型的标准感兴趣:

我现在是如何简化的:

class CommentThread(object):
    def __init__(self, url):
        self.req = requests.get(url)
        self.soup = BeautifulSoup(self.req)
        self.graph = self.parse_thread(self.soup)

    @staticmethod
    def parse_thread(a_soup):
        raise NotImplementedMethod("subclasses should implement this!")

class CommentThreadType1(CommentThread):
    def __init__(self, url):
        super(CommentThreadType1, self).__init___(url)

    @staticmethod
    def parse_thread(url):
        # actual implementation
        a_graph = nx.DiGraph()
        # add nodes, edges and attributes to a_graph
        return a_graph
这是我正在考虑的另一种选择

class CommentThread(object):
    def __init__(self, url):
        self.req = requests.get(url)
        self.soup = BeautifulSoup(self.req)
        self.graph = nx.DiGraph()

class CommentThreadType1(CommentThread):
    def __init__(self, url):
        super(CommentThreadType1, self).__init___(url)
        self.parse_thread(self.url)

    def parse_thread(self, url):
        # add nodes, edges and attributes to self.graph
就功能而言,这两种方法同样有效。我感兴趣的是,是否有充分的理由选择一种方法而不是另一种方法

我看到的唯一考虑因素如下:

选项1:pro:big_方法纯粹是函数式的,从概念上讲,big_方法实际上是一种静态方法,它在所有实例中都做相同的事情;contra:父类尚未实现抽象方法

选项2:赞成:较短,反对:有副作用的方法


是否还有其他重要的概念或风格方面的考虑因素可能会在两个方向上打破平衡?

代码中有一些错误,足以使问题变得不清楚。请包括一个版本的运行代码和存根。一些编辑使它更清楚我所说的。