super() throwing an error in Sublime Text, works in PyCharm/Terminal
作为作业的一部分,我已经生成了以下代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | class Question: """Base class for all questions""" question_count = 0 def __init__(self, desc): self.desc = desc Question.question_count += 1 class MarkovMM(Question): def __init__(self, desc, arrival, service): super().__init__(desc) if self.desc =="Question 2": self.answer = round(1 - (1 - (arrival / service)) - ((1 - (arrival / service)) * (arrival / service)), 3) elif self.desc =="Question 3": self.answer = round(1 / ((service / 60) - (arrival / 60)), 4) qu2 = MarkovMM("Question 2", 5, 23) print(qu2.answer) qu3 = MarkovMM("Question 3", 6, 22) print(qu3.answer) |
当我运行它通过Pycharm和Ubuntu终端时,它工作得很好。但是,在崇高的文本中运行它会产生以下错误。
1 2 3 4 5 6 | Traceback (most recent call last): File"/home/estilen/Dropbox/College/Year_3/CSA2/Python/hello.py", line 20, in <module> qu2 = MarkovMM("Question 2", 5, 23) File"/home/estilen/Dropbox/College/Year_3/CSA2/Python/hello.py", line 14, in __init__ super().__init__(desc) TypeError: super() takes at least 1 argument (0 given) |
为什么错误会出现在崇高的地方,而不是Pycharm或Terminal?
期望输出:
1 2 | 0.047 3.75 |
Sublimetext使用的是默认的构建系统,即python 2。将其配置为在Python3中运行。
添加此内容:
1 2 3 4 5 | { "cmd": ["python3","-u","$file"], "file_regex":"^[ ]*File "(...*?)", line ([0-9]*)", "selector":"source.python" } |
用一个合理的文件名保存配置,比如说