[英]TypeError: Error when calling the metaclass bases module
I'm getting the following error: 我收到以下错误:
Traceback (most recent call last):
File "/Users/user/repos/prodigy/Sweeper/envsweeper/lib/python2.7/site-packages/nose/loader.py", line 414, in loadTestsFromName
addr.filename, addr.module)
File "/Users/user/repos/dr/Sweeper/envsweeper/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Users/user/repos/prodigy/Sweeper/envsweeper/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/user/repos/dr/Sweeper/test.py", line 5, in <module>
from SomethingSubclass import SomethingSubclass
File "/Users/user/repos/dr/Something/SomethingSubclass.py", line 18, in <module>
class SomethingSubclass(SomethingBaseclass):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
This is the code in the Base
class: 这是
Base
类中的代码:
import os
import sys
import inspect
from settings import picklePass, masterMap
from decimal import Decimal
CURRENTDIR = os.path.dirname(
os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(CURRENTDIR)
sys.path.insert(0, parentdir)
from libs.pickler.pickler import Pickler
import logging
class BaseClass(object):
def __init__(self, address, fee, msg_body):
self.address = address
self.fee = (fee)
self.msg_body = msg_body
This would be the code in the SubClass
that is throwing the error, filename: SubClass.py
: 这将是在
SubClass
错误的代码,文件名: SubClass.py
:
import os
import sys
import inspect
import Sweeper
CURRENTDIR = os.path.dirname(
os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(CURRENTDIR)
sys.path.insert(0, parentdir)
from libs.deterministic import electrum_privkey
from libs.transaction import sign, mksend
import logging
sys.path.insert(0, CURRENTDIR)
class SubClass(BaseClass):
def __init__(self, address, fee, msg_body):
BaseClass.__init__(self, address, fee, msg_body)
And this is how the subclass is instantiated: 这是实例化子类的方式:
....
module = __import__('SubClass')
class_ = getattr(module, 'SubClass')
Any clues on what might be wrong? 关于可能出什么问题的任何线索?
from module'name import class'name
Don't use 不要使用
import class'name
if your module and class have the same name. 如果您的模块和类具有相同的名称。 It will confuse the different names.
它将混淆不同的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.