这三个概念是Python为了解决容器对象遍历问题抽象出来的概念. 三者之间的关系是:\(\text{generator}\subset\text{iterator}\subset\text{iterable}\).
python name binding and resolution
这篇主要是翻译了一些官方文档The Python Language Reference第四章的干货, 加入一些自己理解的形象化描述以及一些例子代码. 写这篇的原因是工作原因做了一个从把VBScript转换成Python的工具, 需要复习一遍python的一些基础知识.
Python ast module
由于一个工作需要把大量的vbscript脚本转换成python脚本, 需要学习一下python的ast模块, 本文是一些干货的笔记. 由于当前最新的python 3.8的官方文档过于简略, 主要参考和翻译绿树蛇的文档和python3.10pre的文档.
AST是Abstract Syntax Trees的缩写, 中文是抽象语法树.
AST和code的转换
python代码有三个分身,
- 以unicode字符串存在的源代码. 人类可读写, python解释器不可读.
- 以AST对象存在的抽象语法树. 人类可读写, 但很难读懂原来的语义, 用来显示python语义元素之间的关系. 是从源代码翻译成目标代码的中间产品.
- 以code object存在的可执行的目标代码. python解释器可读, 人类不可读.
A Mathematical Introduction to Logic -- Section 2.2 -- Problem 1 Solution
\(\def\tauequ{\mathbin{\vDash\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\Dashv{\mathbin{\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\DEF{\sf{D\scriptsize EF}.\quad}\) \(\def\DEFi{\sf{D\scriptsize EF}^*.\quad}\) \(\def\DEFn{\sf{D\scriptsize EF}_*.\quad}\) \(\def\DEFin{\sf{D\scriptsize EF}^*_*.\quad}\) \(\def\llbracket{\unicode{x27E6}}\) \(\def\rrbracket{\unicode{x27E7}}\) \(\def\PROOF{\sf{P\scriptsize ROOF}.\quad}\)
Problem 1
Show that (a) \(\Gamma;\alpha\vDash\varphi\) iff \(\Gamma\vDash(\alpha\rightarrow\varphi)\); and (b) \(\varphi\tauequ\psi\) iff \(\vDash(\varphi\leftrightarrow\psi)\).
\(\PROOF\)
A Mathematical Introduction to Logic -- Section 2.2 -- Problem 2 Solution
\(\def\PROOF{\sf{P\scriptsize ROOF}.\quad}\)
Problem 2
Show that no one of the following sentences is logically implied by the other two. (This is done by giving a structure in which the sentence in question is false, while the other two are true.)
- \(\forall{x}\forall{y}\forall{z}(Pxy\rightarrow Pyz\rightarrow Pxz).\) Recall that by our convention \(\alpha\rightarrow\beta\rightarrow\gamma\) is \(\alpha\rightarrow(\beta\rightarrow\gamma).\)
- \(\forall{x}\forall{y}(Pxy\rightarrow Pyx\rightarrow x=y).\)
- \(\forall{x}\exists{y}Pxy\rightarrow\exists{y}\forall{x}Pxy.\)
减肥课听后感
听了得到上冯雪的科学减肥课. 把干货总结一下.
A Mathematical Introduction to Logic -- Section 2.2
\(\def\tauequ{\mathbin{\vDash\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\Dashv{\mathbin{\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\DEF{\sf{D\scriptsize EF}.\quad}\) \(\def\DEFi{\sf{D\scriptsize EF}^*.\quad}\) \(\def\DEFn{\sf{D\scriptsize EF}_*.\quad}\) \(\def\DEFin{\sf{D\scriptsize EF}^*_*.\quad}\) \(\def\llbracket{\unicode{x27E6}}\) \(\def\rrbracket{\unicode{x27E7}}\) \(\def\PROOF{\sf{P\scriptsize ROOF}.\quad}\)
这是一个关于数理逻辑的读书笔记或者学习总结, 书名是A Mathematical Introduction to Logic, 作者Herbert B. Enderton, University of California
本文是Chapter 2, Section 2.2, 点击这里进入AMIL目录
A Mathematical Introduction to Logic -- Section 2.1
\(\def\tauequ{\mathbin{\vDash\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\Dashv{\mathbin{\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\DEF{\sf{D\scriptsize EF}.\quad}\) \(\def\DEFi{\sf{D\scriptsize EF}^*.\quad}\) \(\def\DEFn{\sf{D\scriptsize EF}_*.\quad}\) \(\def\DEFin{\sf{D\scriptsize EF}^*_*.\quad}\) \(\def\llbracket{\unicode{x27E6}}\) \(\def\rrbracket{\unicode{x27E7}}\) \(\def\PROOF{\sf{P\scriptsize ROOF}.\quad}\)
这是一个关于数理逻辑的读书笔记或者学习总结, 书名是A Mathematical Introduction to Logic, 作者Herbert B. Enderton, University of California
本文是Chapter 2, Section 2.1 点击这里进入AMIL目录
A Mathematical Introduction to Logic -- Section 1.7
\(\def\tauequ{\mathbin{\vDash\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\Dashv{\mathbin{\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\DEF{\sf{D\scriptsize EF}.\quad}\) \(\def\DEFi{\sf{D\scriptsize EF}^*.\quad}\) \(\def\DEFn{\sf{D\scriptsize EF}_*.\quad}\) \(\def\DEFin{\sf{D\scriptsize EF}^*_*.\quad}\)
这是一个关于数理逻辑的读书笔记或者学习总结, 书名是A Mathematical Introduction to Logic, 作者Herbert B. Enderton, University of California
本文是Chapter 1, Section 1.7, 点击这里进入AMIL目录
A Mathematical Introduction to Logic -- Section 1.1/1.2
\(\def\tauequ{\mathbin{\vDash\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\Dashv{\mathbin{\style{display: inline-block; transform: scaleX(-1)}{\vDash}}}\) \(\def\DEF{\sf{D\scriptsize EF}.\quad}\) \(\def\DEFi{\sf{D\scriptsize EF}^*.\quad}\) \(\def\DEFn{\sf{D\scriptsize EF}_*.\quad}\) \(\def\DEFin{\sf{D\scriptsize EF}^*_*.\quad}\)
这是一个关于数理逻辑的读书笔记或者学习总结, 书名是A Mathematical Introduction to Logic, 作者Herbert B. Enderton, University of California
本文是Chapter 1, Section 1.1, 1.2, 点击这里进入AMIL目录