Blog
More writing
View archive →
logger.debug causes performance issues
A logger is preferred in a formal project, because we can set different levels for different loggers, redirect log messages to files (even to remot...

Python itertools
最近在工作中使用 python 开发时经常需要将多个 iterator 进行一些操作。以前的惯用手法要么是主动 使用 for 循环,要么是使用 zip 将多个 iterator 打平成多个。其实一直知道 itertools 这个库 的,只是偶尔会用,并没有去仔细研究过。

Python tempfile module
在开发的过程中,我们时常需要创建一些临时目录或者临时文件来保存一些状态。在 python 中一般 会使用 tempfile 这个模块。之前其实一直都是利用它的 gettempdir 来获取一个临时目录,然后在 临时目录中创建文件,最后在清理掉。实际上 tempfile 可以更加的智能。

tmux conf
TMux is really awesome when you want to run commands on servers. But due to all kinds of reasons, you may lose the connection. If you reconnect to ...

Buffer only in vim
I am using coc-pywright to jump to the definition for programming in python. I have set it up to open a vertically split window. Sometimes I just w...

Base64 in python
Base64 encode and decode are used in many places. What is base64 and how to implement base64 encode and decode in python?

Date and string format in python
在 Python 中生成字符串有 3 种方式,现在比较建议的是使用 f-str 的方式,官方说性能更加好。本文主要 介绍在格式化时有哪些格式可以选择。

Python command line comparison
编写 Python 的命令行程序时,一个很重要的问题是:如何声明参数,然后解析,最终被程序调用。能否灵活的 声明,组合会决定我们是否需要用额外的代码来替代这些功能。例如参数的互斥,子命令等。

Add Unique ID for Http Request
后端服务的每一次请求会进入各种逻辑,发生各种问题。在大并发情况下,不同请求之间的 日志还会混在一起。

Who passes the additional argument to my `fn` ?
Recently in an implementation of a functionality, following error keeps showing and drives me crazy.