Guide#

How to debug#

  1. Run ipython.
  2. If an error occurs, run
debug
up
up
down
quit

ipython automatically launches ipdb, a version of pdb.

How to test script#

Reloading module in interpreter#

For normal interactive python, run

import <module> as m
from importlib import reload
# After making changes
reload(m)

For Ipython and Jupyter Notebook (And Hydrogen), run

%load_ext autoreload
%autoreload 2
# Load modules after running these 2 commands
import <module> as m
# The module will reload automatically before any execution

Writing Packages#

Learn how to organize a python module/package. https://towardsdatascience.com/whats-init-for-me-d70a312da583

Logging#

https://www.loggly.com/ultimate-guide/python-logging-basics/

Importing packages from parent folder#

link

import sys, os, inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)