第3章:字典和集合
泛映射类型 可散列的数据类型 An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__() method), and can be compared to other objects (it needs an __eq__() method). Hashable objects which compare equal must have the same hash value.
字典推导 dict Comprehensions
用setdefault处理找不到的键 my_dict.setdefault(key, []).append(new_value)
OrderedDict defaultdict
第5章:函数
一等对象/一等函数: Elements with the fewest restrictions are said to have first-class status. Some of the ''rights and privileges'' of first-class elements are: 1. They may be named by variables. 2. They may be passed as arguments to procedures. 3. They may be returned as the results of procedures. 4. They may be included in data structures. https://www.zhihu.com/question/32002222
把函数视作对象
高阶函数(High-order Function):接受函数为参数,或者把函数走位结果返回的函数。
匿名函数(Anonymous/Lambda Function):https://eastlakeside.gitbooks.io/interpy-zh/content/Lambdas/
可调用对象(Callable Object):A callable object is an object that can accept some arguments (also called parameters) and possibly return an object (often a tuple containing multiple objects). A function is the simplest callable object in Python, but there are others, such as classes. 内置callable()函数判断对象是否可调用。
用户定义的可调用类型:_ _call_ _
函数内省(function introspection)
从定位参数到仅限关键字参数:This PEP proposes a change to the way that function arguments are assigned to named parameter slots. In particular, it enables the declaration of "keyword-only" arguments: arguments that can only be supplied by keyword and which will never be automatically filled in by a positional argument.
获取关于参数的信息
函数注解
第6章:使用一等函数实现设计模式