小编Jul*_*les的帖子

Python:在未绑定的方法调用中没有参数'filenames'的值

我有一个类来包装我的程序的配置内容.但是当我尝试在ipython中测试我时:

c = Config(test.cfg)
Run Code Online (Sandbox Code Playgroud)

我收到错误:

"TypeError: read() missing 1 required positional argument: 'filenames'
"
Run Code Online (Sandbox Code Playgroud)

但是我的pylint在我的emacs中抛出了这个错误:

"No value for argument 'filenames' in unbound method call"
Run Code Online (Sandbox Code Playgroud)

我认为错误是上面的错误的原因.但我不知道为什么.我认为该方法是调用绑定的,因为我使用self作为参考,但我不是shure而且我不明白为什么它不接受cfg作为参数.

这是我的班级:

from configparser import ConfigParser

class Config:
    """Wrapper around config files
    Args:
        cfg: main config file
    """
    def __init__(self, cfg=None):
        self.cfg = []
        self.cfgraw = cfg
        self.scfgs = []
        self.scfgs_raw = []
        if not cfg is None:
            self.add(typ="main", cfg=cfg)


    def add(self, typ, cfg):
        """add config file
        Args:
             typ: type of file main or sub
        Returns: …
Run Code Online (Sandbox Code Playgroud)

python

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×1