Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on Monkey Patching in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

A MonkeyPatch is a piece of Python code which extends or modifies other code at runtime (typically at startup).

A monkey patch is a way for a program to extend or …

Use Qt in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

PyQt5 vs PySide2

https://www.reddit.com/r/Qt5/comments/a3zt3j/eli5_pyqt5_pyside2_which_one_to_use/

Both PyQt5 (developed by Riverbank) and PySide2 (official Python bindings from Qt) are great. They have very similar APIs …

Add Method to a Python Class

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

https://www.ianlewis.org/en/dynamically-adding-method-classes-or-class-instanc

http://block.arch.ethz.ch/blog/2016/07/adding-methods-to-python-classes/

Preferred Python Version in Shebang

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

#!/bin/sh
''''which python2 >/dev/null 2>&1 && exec python2 "$0" "$@" # '''
''''which python  >/dev/null 2>&1 && exec python  "$0" "$@" # '''
''''exec echo "Error: I can't find python anywhere"         # '''

Reference

https …

Python Packaging Tools

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Python packaging:

https://python-packaging.readthedocs.io/en/latest/minimal.html

  1. It is recommended to use PyBuilder to manager Python projects.

pyinstaller

setuptools

pip

pip can install a package from a GitHub …