Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on Xonsh

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

https://github.com/xonsh/xonsh/wiki/Cheatsheet

Tricks and Traps

  1. While $() in xonsh works similar to $() in (all variants of) shell, it cannot be used in the middle of argument of …

Calling Shell from Python

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

  1. subprocess.run is preferred to the function os.system for invoking shell commands. For more discussions, pleaser refer to [Hands on the Python module subprocess]https://www.legendu.net/en/blog …

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 …