>>> cli_timestamp_to_ns("123") # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
python_utils.custom_exceptions.InvalidCLITimestampError: Invalid timestamp provided: 123

Print numpy array without truncation:

np.set_printoptions(threshold=sys.maxsize)

Quaternions:

There's a gazzilion of 2D statistics/plotting libraries in python. Just select a single damn one and stick to it - None of it supports 3D visualisation

Only thing that's available (~end 2019) is matplotlib. Just use it...

parser = argparse.ArgumentParser(description="Help line 1\n" +
                                             "Help line 2",
                                 formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))

Example usage: https://www.data-structures-in-practice.com/hash-tables/

Use the dis standard library module: https://docs.python.org/3/library/dis.html Use it e.g., on a function:

import dis
f = lambda x: x + 2
dis.dis(f)
1           0 LOAD_FAST                0 (x)
            2 LOAD_CONST               1 (2)
            4 BINARY_ADD
            6 RETURN_VALUE

Normally you'd do this as part of your bashrc/fish.config file. But if you haven't, here's the commands to do it in the current shell instance

fish )
    set -x PATH \"${PYENV_ROOT}/bin\" \$PATH
    status --is-interactive; and . (pyenv init -|psub)
    status --is-interactive; and . (pyenv virtualenv-init -|psub)
    ;;
* )
    PYENV_ROOT="$HOME/.pyenv"
    export PATH="${PYENV_ROOT}/bin:$PATH"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
from sympy import var, cos, plot
x = var('x')
p = plot(cos(x), line_color='r')
p = plot(cos(2*x), line_color='g')
p = plot(cos(4*x), line_color='b')
pl.extend(plot(cos(2*x), line_color='g'))
pl.show()
numpy.set_printoptions(linewidth=160)
(Pdb++) p T
array([[ 1.00000000e+00,  1.00284240e-18, -2.28654607e-18,
         0.00000000e+00],
       [ 1.13765545e-18,  1.00000000e+00,  1.29264105e-19,
         0.00000000e+00],
       [-1.39240192e-17,  1.34405256e-19,  1.00000000e+00,
         3.46944695e-18],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         1.00000000e+00]])
(Pdb++) numpy.set_printoptions(linewidth=160)
(Pdb++) p T
array([[ 1.00000000e+00,  1.00284240e-18, -2.28654607e-18,  0.00000000e+00],
       [ 1.13765545e-18,  1.00000000e+00,  1.29264105e-19,  0.00000000e+00],
       [-1.39240192e-17,  1.34405256e-19,  1.00000000e+00,  3.46944695e-18],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
(Pdb++)

https://github.com/albertlauncher/python/pull/96/files

bus = dbus.SessionBus()
notify = dbus.Interface(bus.get_object(dbusItem, dbusPath), dbusInterface)
notify.Notify(__prettyname__, 0, iconPath, title, text, '', '', 0)
spec = importlib.util.spec_from_file_location("bing", "plugins/image_search/bing.py")
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)

cl = foo.MyClass()

Every module and object in python has a __dict__ attribute (you can think of all the modules as dictionaries that contain their variables, and functions)

Use self.__class__.__bases__

Link: https://stackoverflow.com/a/10092179/2843583