[读书笔记] 流畅的python / Fluent Python

 

第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章:使用一等函数实现设计模式

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值