-
Mutable default arguments
A new list is created once when the func is defined, and the same list is used in each successsive call: Python's default arguments are evaluated once when the func is defined, not each time the func is called.
This means that if you use a mutable default argument and mutate is, you will have mutated that object fro all future calls to the function as well.
(But sometimes this gotcha could not be a gotcha,for instance,you want to maintain state between calls of a function like cache)
Late binding closures
What you you should do instead
the one:
the two:
Python package name can not contains '-' character
在对一个list进行pop操作时,必须是按逆序来删除。即,先删下标大的元素,再删下标小的元素,否则 会越界。
5.在使用sorted对iterable进行排序的时候,并不会改变传进来的iterable。而是生成一个新的排序好的iterable并return。
num = 1
def t():
print(num)
# 在进行赋值操作时,解释器默认变量为本地变量
num += 1
t()
解决办法 声明 global num
- decimal module. https://www.v2ex.com/t/415039
8, 解决 Windows 下 Python 的 too many file descriptors in select() 报错