python flask 部分源码理解

#偏函数
from functools import partial
def demo(a,*args):
print(a)
print(args)

par_fun = partial(demo,1)
par_fun(3,3,4,5)



线程安全(local)空间换时间
from threading import local
from threading import Thread
from time import sleep


class Foo(local):
pass


foo = Foo()


def demo(i):
foo.i = i
sleep(1)
print("------")
print(foo.i, i)




for i in range(20):
th = Thread(target=demo,args=(i,))
th.start()
原文地址:https://www.cnblogs.com/ls1997/p/11638516.html