[PYTHON] Shell script for people who have trouble with mkdir + touch __init__.py

When creating a package with Python, it will not be recognized as a package unless you put __init__.py in the mkdir directory.

So, if you do it normally, you have to hit mkdir + touch __init__.py twice, which is very troublesome. So, I prepare a command called pydir for myself, and in addition to creating a directory, I also ask him to create __init __. Py.

The content is just a shell script, so feel free to use it in any way you like.

python


#!/bin/bash

if [ $# -ne 1 ]; then
    echo "usage: pydir dir_name"
    exit 1
fi

mkdir $1
cd $1
touch __init__.py
cd ..
exit 0

Recommended Posts

Shell script for people who have trouble with mkdir + touch __init__.py
Automate environment construction with Shell Script