【发布时间】:2013-01-05 23:05:21
【问题描述】:
我正在处理使用warnings 库引发大量(目前对我而言)无用警告的代码。阅读(/扫描)文档我只找到了to disable warnings for single functions的方法。但我不想更改这么多代码。
有python -no-warning foo.py这样的标志吗?
你会推荐什么?
【问题讨论】:
-
@MartinSamson 我大体上同意,但在某些情况下可以忽略警告。我通过在 defusedxml 中使用有效的 Xpath 语法获得了其中的几个:
FutureWarning: This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to [this other thing]。我宁愿现在忽略警告并等待它被静默修复,也不愿编写不必要的丑陋代码来避免无害的警告。