Skip to content

Instantly share code, notes, and snippets.

#!usr/bin/env python3
# -*- coding: utf-8 -*-
"""
关于async for 和 __aiter__、__anext__
old __aiter__ protocol, reutrn awaitable.
In 3.5.2 __aiter__ protocol was updated to return asynchronous iterators directly.
In CPython 3.7, the old __aiter__ protocol will no longer be supported: a RuntimeError will be raised
if __aiter__ returns anything but an asynchronous iterator.
#! usr/bin/env python3
# -*- coding: utf-8 -*-
"""
aiomysql_bug_in_ResultProxy.py
aiomysql的官方例子在python 3.7中的async for问题,例子会报错
aiomysql 0.0.20
源码:
ResultProxy
# closure_lambda_lazy
Closure:
内部函数引用的是外部函数的参数或变量,但是引用的是变量的最终值(外部函数的那次生命周期,外部函数可跨层级)
内层函数作为值返回时不会直接运算,等调用它的时候才会运算
看几个例子
# 1.Lazy, 另外内部函数引用了外部函数的参数,且外部函数生命周期已经结束不影响其使用.
>>> lazy_square_print = lambda i: lambda: print(i**2)
>>> square_print = lazy_square_print(5)

1. Editor -> File and Code Templates -> Python Scripts

#!usr/bin/python3
# -*- coding: utf-8 -*-

"""
@file:${NAME}.py
@time:${YEAR}/${MONTH}/${DAY}
@author:${USER}
"""
#!usr/bin/env python3
# -*- coding: utf-8 -*-
"""
oneline if-else could be replaced by and/or
1. a if a else b -> a or b
2. f if a else g -> a and f or g # tricky though, so don't use, coz f must be true-like value.
"""
def f():
@mildcore
mildcore / Pycharm Keymap
Created July 18, 2020 09:18
Pycharm快捷键
常用快捷键
1、编辑(Editing)
Ctrl + Space:基本的代码完成(类、方法、属性)
Ctrl + Alt + Space:快速导入任意类
Ctrl + Shift + Enter:语句完成
Ctrl + P:参数信息(在方法中调用参数)
Ctrl + Q:快速查看文档
F1:外部文档
Shift + F1:外部文档,进入web文档主页
Ctrl + Shift + Z:Redo 重做
@mildcore
mildcore / speedtest-server-list.txt
Created August 21, 2021 20:13 — forked from stawidy/speedtest-server-list.txt
Speedtest 节点列表
17584) Chongqing Mobile Company (Chongqing, CN)
5726) China Unicom Chong Qing Branch (Chongqing, China)
5530) CCN (Chongqing, China)
19076) China Telecom (ChongQing, China)
20054) YunJinTianFu (Chengdu, China)
11444) University of Electronic Science and Technology of China (Chengdu, China)
2461) China Unicom (Chengdu, China)
4575) China Mobile Group Sichuan (Chengdu, China)
16398) China Mobile,GuiZhou (Guiyang, China)
5292) China Mobile Group Shaanxi Company Limited (Xi'an, China)