[英]Python - change module name, for more meaningful errors
Right now, I have custom classes I import like so: 现在,我有导入的自定义类,如下所示:
import lib.directory as d
Then make an instance like: 然后创建一个实例,例如:
directory = d.directory()
Then, in the process of using several of these classes in lib
, I run into an error, say: 然后,在
lib
中使用其中几个此类的过程中,我遇到一个错误,说:
File "./process.py", line 94, in <module>
raise e
ValueError: Extra data: line 2 column 1 - line 3 column 1 (char 597 - 677)
How can I change the in <module>
part to something more meaningful? 如何将
in <module>
部分的内容更改为更有意义的内容? Where does that value come from? 这种价值从何而来?
Cheers! 干杯!
File "./process.py", line 94, in <module>
means that line 94 in ./process.py
was not inside a function. File "./process.py", line 94, in <module>
中第94 File "./process.py", line 94, in <module>
表示./process.py
中的94行不在函数内。 It was a module-level function call. 这是一个模块级的函数调用。 If the error was in a function, the function name would appear instead of
<module>
. 如果错误出在函数中,则会出现函数名称而不是
<module>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.