我有一个python文件。我可以在Python2.7上运行它而没有任何问题,但不能在Python3.6上正确运行它。 Python文件是
__all__ = ['ParallelWrapShotNull', 'ParallelWrapShot']
class ParallelWrapShotBase(object):
def __init__(self, *args, **kwargs):
raise NotImplementedError('ParallelWrapShotBase.__init__ should never be called.')
class ParallelWrapShotNull(ParallelWrapShotBase):
def __init__(self, *args, **kwargs):
self.comm = None
self.use_parallel = False
self.size = 1
self.rank = 0
class ParallelWrapShot(ParallelWrapShotBase):
def __new__(cls, *args, **kwargs):
return super(ParallelWrapShot, cls).__new__(cls, *args, **kwargs)
# return super().__new__(cls, *args, **kwargs)
def __init__(self, comm=None, *args, **kwargs):
if comm is None:
self.comm = 1
else:
self.comm = 2
self.use_parallel = True
self.size = 3
self.rank = 4
if __name__ == '__main__':
y = ParallelWrapShotNull()
z = ParallelWrapShot('foo')
我收到的错误消息是:
Traceback (most recent call last):
File "test_exp.py", line 45, in <module>
z = ParallelWrapShot('foo')
File "test_exp.py", line 23, in __new__
return super(ParallelWrapShot, cls).__new__(cls, *args, **kwargs)
TypeError: object() takes no parameters
我认为Python3.6中的Python 2.7必须有所改变。谁能帮我吗?