文章目录
- Structure of the Examples/示例结构
- Usage/用法
- ? Examples/示例
-
- Section: Strain your brain!/大脑运动!
-
- > Strings can be tricky sometimes/微妙的字符串 *
- > Time for some hash brownies!/是时候来点蛋糕了!
- > Return return everywhere!/到处返回!
- > Deep down, we're all the same./本质上,我们都一样. *
- > For what?/为什么?
- > Evaluation time discrepancy/执行时机差异
- > `is` is not what it is!/出人意料的`is`!
- > The sticky output function/麻烦的输出
- > `is not ...` is not `is (not ...)`/`is not ...` 不是 `is (not ...)`
- > The surprising comma/意外的逗号
- > Backslashes at the end of string/字符串末尾的反斜杠
- > not knot!/别纠结!
- > Half triple-quoted strings/三个引号
- > Midnight time doesn't exist?/不存在的午夜?
- > What's wrong with booleans?/布尔你咋了?
- > Class attributes and instance attributes/类属性和实例属性
- > yielding None/生成 None
- > Mutating the immutable!/强人所难
- > The disappearing variable from outer scope/消失的外部变量
- > When True is actually False/真亦假
- > From filled to None in one instruction.../从有到无...
- > Subclass relationships/子类关系 *
- > The mysterious key type conversion/神秘的键型转换 *
- > Let's see if you can guess this?/看看你能否猜到这一点?
- Section: Appearances are deceptive!/外表是靠不住的!
- Section: Watch out for the landmines!/小心地雷!
-
- > Modifying a dictionary while iterating over it/迭代字典时的修改
- > Stubborn `del` operator/坚强的 `del` *
- > Deleting a list item while iterating/迭代列表时删除元素
- > Loop variables leaking out!/循环变量泄漏!
- > Catching the Exceptions/捕获异常
- > Same operands, different story!/同人不同命!
- > The out of scope variable/外部作用域变量
- > Be careful with chained operations/小心链式操作
- > Name resolution ignoring class scope/忽略类作用域的名称解析
- > Needle in a Haystack/大海捞针
- Section: The Hidden treasures!/隐藏的宝藏!
-
- > Okay Python, Can you make me fly?/Python, 可否带我飞? *
- > `goto`, but why?/`goto`, 但为什么? *
- > Brace yourself!/做好思想准备 *
- > Let's meet Friendly Language Uncle For Life/让生活更友好 *
- > Even Python understands that love is complicated/连Python也知道爱是难言的 *
- > Yes, it exists!/是的, 它存在!
- > Inpinity/无限 *
- > Mangling time!/修饰时间! *
- Section: Miscellaneous/杂项
Structure of the Examples/示例结构
python3 改为默认的python 版本
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
如果要切换到Python2,执行:
sudo update-alternatives --config python
Usage/用法
我个人建议, 最好依次阅读下面的示例, 并对每个示例:
- 仔细阅读设置例子最开始的代码. 如果您是一位经验丰富的 Python 程序员, 那么大多数时候您都能成功预期到后面的结果.
- 阅读输出结果,
- 确认结果是否如你所料.
- 确认你是否知道这背后的原理.
- 如果不知道, 深呼吸然后阅读说明 (如果你还是看不明白, 别沉默! 可以在这提个 issue).
- 如果知道, 给自己点奖励, 然后去看下一个例子.