Easy filter management with Python's -m option

You can start a module by passing the -m option and the module name when starting Python. For example, the built-in module json.tool receives json as a character string, formats it, and outputs it as shown below.

% echo '{"json":"obj"}' | python -m json.tool
{
    "json": "obj"
}
% echo '{ 1.2:3.4}' | python -m json.tool
Expecting property name: line 1 column 2 (char 2)

It is convenient to use this to manage frequently used filters. First, write .bashrc or .zshrc to add an appropriate directory to the PYTHONPATH environment variable. Here, it is $ HOME / pythonpath.

export PYTHONPATH=$HOME/pythonpath:$PYTHONPATH

Next, create a module like $ HOME / pythonpath / filter.

% mkdir -p ~/pythonpath/filter
% touch ~/pythonpath/__init__.py ~/pythonpath/filter/__init__.py

Now you can easily call it by putting a Python script in $ HOME / pythonpath / filter. For example, the script $ HOME / pythonpath / filter / hoge.py would be python -m filter.hoge.

Recommended Posts

Easy filter management with Python's -m option
Manage filters with Python's -m option # 2
Easy Grad-CAM with pytorch-gradcam
Routine management with calendar
Create filter with scipy
Easy debugging with ipdb
Easy TopView with OpenCV
I tried follow management with Twitter API and Python (easy)