# tools - for `tox` and `setuptools` see [sampleproject](https://github.com/pypa/sampleproject) - `pydoc3` prints api of modules # logging levels - `CRITICAL` - `ERROR` - `WARNING` - `INFO` - `DEBUG` - `NOTSET` # pip ```sh # install in user home pip install --user [extra_tags] # don't update deps pip install --upgrade --upgrade-strategy only-if-needed # directly from github zipfile pip install https://github.com///zipball/ # clear cache (linux) rm -rf ~/.cache/pip/ ``` # tox by default installs current package as dep. additional deps must be specified. # readthedocs doesn't respect my makefile, instead reads conf.py. thus apidoc must be called from conf, which kinda breaks doctests. # uml gibt bilder zum code: pip install pylint pyreverse -o png # virtualenvwrapper all virtualenv will be installed under `$WORKON_HOME`. projects live under `$PROJECT_HOME`. ```sh . /usr/local/bin/virtualenvwrapper.sh mkvirtualenv name workon name # if `.` is given name is derived from basename of cwd cdvirtualenv # cd to current virtualenv directory cdsitepackages # cd to current site packages directory lssitepackages deactivate ``` ## projects when virtualenv is connected to a project `workon` will also cd into project. ```sh mkproject name # when you got lost: cdproject ``` to connect already existing virtualenv w/ project: ```sh setvirtualenvproject $VIRTUAL_ENV $(pwd) ``` more: - `wipeenv`: remove all third-party packages in current virtualenv - `cpvirtualenv` - `mktmpenv` - `lsvirtualenv` - `rmvirtualenv`, must `deactivate` first # tests - `unittest`: `python -m unittest ` - `doctest`: `python -m doctest ` restrict executed tests w/ keyword expressions `-k`, w/ can contain python operators that use filenames, class names and function names. ```sh pytest tests/test_main.py -k 'test_main' ``` # language nested loops, irritating order, just read from left to right: ```python [item for row in table for item in row] ``` `__repr__` is to be unambiguous, `__str__` is to be readable. container's `__str__` uses contained objects' `__repr__`. almost every object you implement should have a functional __repr__, `__str__` is optional.