在python中将迭代器传递给parrent类init

在python中将迭代器传递给parrent类init,python,python-3.x,oop,Python,Python 3.x,Oop,我想做的是围绕gensim中的Doc2Vec类,并为其提供一种培训方法。通常,如果我想培训一种新车型,我会做以下工作: import glob from gensim.models import doc2vec, Doc2Vec class tagged_documents(object): def __init__(self, path): self.file_l = [name for name in glob.iglob(path, recursive=True

我想做的是围绕
gensim
中的
Doc2Vec
类,并为其提供一种培训方法。通常,如果我想培训一种新车型,我会做以下工作:

import glob
from gensim.models import doc2vec, Doc2Vec


class tagged_documents(object):
    def __init__(self, path):
        self.file_l = [name for name in glob.iglob(path, recursive=True)]
    
    def __iter__(self):
        for f_id, f_path in enumerate(self.file_l):
            with open(f_path, 'r') as f:
                docu = f.read()
                yield doc2vec.TaggedDocument(words=docu, tags=(f'DOC_{f_id}',))



Docs = tagged_documents('/path/to/docs/*')
    
Doc2Vec(Docs, min_count = 100, 
                 vector_size=300, 
                 epochs = 20, 
                 negative = 5, 
                 workers=20, 
                 sample = 1e-5,
                 alpha=0.01,
                 min_alpha=0.0001)
这个很好用

现在我要做的是这个包装

class doc2vec_model(Doc2Vec):

    def train(self,docs):
        super(Doc2Vec, self).__init__(docs, min_count = 100, 
                                     vector_size=300, 
                                     epochs = 20, 
                                     negative = 5, 
                                     workers=20, 
                                     sample = 1e-5,
                                     alpha=0.01,
                                     min_alpha=0.0001)

        
Docs = tagged_documents('/path/to/docs/*')
model = doc2vec_model()
model.train(Docs)

当我试图调用
model.train()
函数时,
TypeError:“NoneType”对象是不可编辑的,这是一个例外?使用
super
从不同的方法调用您父母的
\uuuuu init\uuuuu
方法是一个很奇怪的选择,充其量是。
Doc2Vec.\uuuu init\uuuu
也已被调用;由于您没有定义
doc2vec\u模型。\uuuu init\uuuu
,因此在定义
模型时会调用继承的方法。