这个很难, python很难
Queue是一个线程安全的类吗
wrapper的一个用处,给函数打日志
1 | import time |
运行结果:
1 | func bar, param ((), {}), time 0.0, return hello |
function的属性
1 | __name__ |
偏函数 Partial, 柯里化 Currying
补充一下刚才的代码
1 | import time |
1 | <class 'functools.partial'> |
Uncurrying
1 |
|
1 | func add, param ((1,), {}), time 0.0, return <function add.<locals>.add at 0x0000001567C500D0> |
如何写一个满足add(2)至无穷个括号的函数?
0x0000001567C500D0是内存地址?
可以操作内存吗?
Generator
1 | a_generator = (item**2 for item in range(200)) |
1 | 0 |
生成质数
1 | log_next = logger(next) |
1 | func next, param ((<generator object prime at 0x000000450FF4A728>,), {}), time 0.0, return 2 |
eval, compile,code ?