跳转至

2020-11-0x01

keywords: Python Vscode Wikipedia APSD

Note

Python

https://docs.python.org/3/library/typing.html

NewType

利用 NewType 可以定义一个新的检查类型

from typing import NewType

UserId = NewType('UserId', int)
some_id = UserId(524313)

Callable type

Callable[[int], str] is a function of (int) -> str.

Optional type

You can use Optional[X] as a shorthand for Union[X, None].

Literal type

A type that can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals). For example:

def validate_simple(data: Any) -> Literal[True]:  # always returns True
    ...

MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
    ...

open_helper('/some/path', 'r')  # Passes type check
open_helper('/other/path', 'typo')  # Error in type checker

Final type

A special typing construct to indicate to type checkers that a name cannot be re-assigned or overridden in a subclass. For example:

MAX_SIZE: Final = 9000
MAX_SIZE += 1  # Error reported by type checker

class Connection:
    TIMEOUT: Final[int] = 10

class FastConnector(Connection):
    TIMEOUT = 1  # Error reported by type checker

Constant type

TYPE_CHECKING type

A special constant that is assumed to be True by 3rd party static type checkers. It is False at runtime. Usage:

if TYPE_CHECKING:
    import expensive_mod

def fun(arg: 'expensive_mod.SomeType') -> None:
    local_var: expensive_mod.AnotherType = other_fun()
The first type annotation must be enclosed in quotes, making it a forward reference, to hide the expensive_mod reference from the interpreter runtime. Type annotations for local variables are not evaluated, so the second annotation does not need to be enclosed in quotes.

软件设计哲学笔记

https://github.com/gdut-yy/A-Philosophy-of-Software-Design-zh/blob/master/docs/ch7.md

创建装饰器类之前,请考虑以下替代方法: 您能否将新功能直接添加到基础类,而不是创建装饰器类?如果新功能是相对通用的,或者在逻辑上与基础类相关,或者如果基础类的大多数使用也将使用新功能,则这是有意义的。例如,几乎每个创建 Java InputStream 的人都会创建一个 BufferedInputStream,并且缓冲是 I/O 的自然组成部分,因此应该合并这些类。 如果新功能专用于特定用例,将其与用例合并而不是创建单独的类是否有意义? 您可以将新功能与现有的装饰器合并,而不是创建新的装饰器吗?这将导致一个更深的装饰器类,而不是多个浅的装饰器类。 最后,问问自己新功能是否真的需要包装现有功能

https://github.com/gdut-yy/A-Philosophy-of-Software-Design-zh/raw/master/docs/figures/00016.gif

https://github.com/gdut-yy/A-Philosophy-of-Software-Design-zh/blob/master/docs/ch11.md

「两次设计」方法不仅可以改善您的设计,而且可以提高您的设计技能。设计和比较多种方法的过程将教您使设计更好或更坏的因素。随着时间的流逝,这将使您更容易排除不良的设计并磨练真正的出色设计

https://github.com/gdut-yy/A-Philosophy-of-Software-Design-zh/blob/master/docs/ch13.md

我最近一直在尝试一种方法,该方法将跨模块问题记录在一个名为 designNotes 的中央文件中。该文件分为清楚标记的部分,每个主要主题一个

Python doc

https://docs.python.org/zh-cn/3.8/glossary.html#term-docstring

Share

wikipedia 缩进风格

https://zh.wikipedia.org/wiki/%E7%BC%A9%E8%BF%9B%E9%A3%8E%E6%A0%BC

播客 shownotes 搜索引擎

https://www.listennotes.com/zh-hans/

wikipedia 计算机编程

https://zh.wikipedia.org/wiki/Category:%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BC%96%E7%A8%8B

中文自然语言 stopword

https://www.ranks.nl/stopwords/chinese-stopwords

v20201102: 的一不在人有是为以于上他而后之来及了因下可到由这与也此但并个其已无小我们起最再今去好只又或很亦某把那你乃它吧被比别趁当从到得打凡儿尔该各给跟和何还即几既看据距靠啦了另么每们嘛拿哪那您凭且却让仍啥如若使谁虽随同所她哇嗡往哪些向沿哟用于咱则怎曾至致着诸自

Vscode Extension: Increment Selection

https://marketplace.visualstudio.com/items?itemName=albymor.increment-selection

让 Vscode 支持序号查询的插件

https://github.com/albymor/Increment-Selection/raw/master/images/demo.gif

Default Keymap

Win\Linux: - ctrl + alt + I - ctrl + shift + P => Increment Selection

Mac: - cmd + alt + I - cmd + shift + P => Increment Selection

Github 增强下载

https://greasyfork.org/zh-CN/scripts/412245-github-%E5%A2%9E%E5%BC%BA-%E9%AB%98%E9%80%9F%E4%B8%8B%E8%BD%BD

Release、Code(ZIP) 文件加速: - https://gh.con.sh | 美国

Git Clone 加速:

Raw 文件加速:

Tutorials

如何维护更新日志

https://keepachangelog.com/zh-CN/1.0.0/

变动类型:

  • Added 新添加的功能。
  • Changed 对现有功能的变更。
  • Deprecated 已经不建议使用,准备很快移除的功能。
  • Removed 已经移除的功能。
  • Fixed 对bug的修复
  • Security 对安全的改进

Python request advance usage

https://findwork.dev/blog/advanced-usage-python-requests-timeouts-retries-hooks/

Mkdcos 支持中文搜索

zimuZhao/mkdocs-demo

语义化版本

https://semver.org/lang/zh-CN/


最后更新: 2021-07-11
创建日期: 2020-11-10