Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Runtime Paths in Python

__file__ is the path of the Python script. Note that if you make a sybolic link to a Python script and run the symbolic link, then __file__ is the path of the symbolic link. Of course, you can use os.path.realpath to get real path of files.

pathlib.Path …

Good Ways to Do Scientific Computing

  1. Break down the work into smaller modules and develop pipelines (consists of module) for the work. Be sure to save (important) intermediate results so that you can resume failed modules withouting reruning succeeded ones.

  2. Manage your project in GitHub and use issues to manage tasks to do and their priorities …

Compare Two Directories on Linux

On the Same Machine

If the two directories are on the same machine, you can use either colordiff (preferred over diff) or git diff to find the differences between them.

colordiff -qr dir_1 dir_2
git diff --no-index dir_1 dir_2

On Different Machines

It is a little bit tricky when the …