https://github.com/ajalt/fuckitpy转
https://www.jb51.net/article/164449.htm的例子
假设有一个目标文件: broke.py
def f():
broken_code
print('fuckit chaining works')
for
let's just assume this is a big module of shitty code.
x = y
y = x
1 / 0 # Oh shhhiiiiiii
var = "Are you proud of what you've done?"
broke.py 中有几处明显的错误,包括语法错误,变量 broken_code 没有被定义,还有0当作被除数。
如果直接 import broke 肯定会报错
>>> import broke
File "broke.py", line 5
for
^
SyntaxError: invalid syntax
这时你可以使用 fuckit 将 broke 导入进来。
>>> import fuckit
>>> fuckit("broke")
<module 'broke' from 'broke.py'>
>>> broke
<module 'broke' from 'broke.py'>
调用函数 f 的时候也会报错
>>> broke.f()
NameError: global name 'broken_code' is not defined
你可以使用链式 fuckit 来调用这个有问题的函数
>>> fuckit(broke).f()
fuckit chaining works
或者
>>> fuckit(fuckit("broke")).f()
fuckit chaining works
--
FROM 117.140.170.*