Ben Chuanlong Du's Blog

It is never too late to learn.

Debug Code in JupyterLab Notebooks

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

Use the %debug Magic

The easiest way to debug a Jupyter notebook is to use the %debug magic command. Whenever you encounter an error or exception, just open a new notebook …

Python Virtual Environment

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

  1. venv is a standard Python library and is the recommended way for managing virtual environments in Python3.

  2. When developing a Python project, it is recommended that you use Poetry to manage …

Copy Object in Python

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

You can use the copy module to copy objects in Python. Customized coping behavior can be achived by overriding the methods __copy__ (for shallow copy) and __deepcopy__ (for deep copy).

References …

Return a New Object Or Mutate the Existing Object

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

Generally speaking, prefer to return a new object rather than mutating the existing object. This is true in most programming languages besides C who seeks for best peformance.

The pandas package …