golb

Python

How to print the error name

try:
    #code here
except Exception as exception:
    print(type(exception).__name__)
    print(exception.__class__.__name__)
    print(exception.__class__.__qualname__)

Reference : stackOverflow

How to get the KeyboardInterrupt

try:
    #code here
except KeyboardInterrupt:
    pass
    #or do something

Pylint

python3 -m pip install pylint
pylint <filename>

The Zen of Python

python -c "import this"

Get the path to a package

python -c "import numpy as _;print(_.__path__)"
python -c "import numpy as _;print(_.__file__)"

Simple http server

python -m http.server

Pip config

Location:

# show the location
pip config debug
# location location and config
pip config -v list