Lessons from Python
(back to the tools page)
From Intermediate Python Practical Techniques for Deeper Skill Development by Steve Holden, O'Reilly Media April 2014
From personal usage
- virtualenv
- virtualenvwrapper
mkvirtualenv --python=/usr/bin/python3 X
workon
to list available virtualenvs
workon X
to active virtualenv X
- updating (e.g. from 3.4 to 3.5, assuming 3.5 as make altinstall rather than system default)
cd targetenv
pip freeze > requirments.txt
deactivate targetenv
mv ~/.virtualenvs/targetenv{,-backup3.4}
mkvirtualenv --python=/usr/local/bin/python3.5 -r requirments.txt
- pip install might fail if so pip install -r requirments.txt after
- eventually pip upgrades after
- ... and testing to make sure it all still works
- matplotlib
plt.close('all')
to close all opened plots, practical during iPython tests
- Python 3
print('This is working!')
python -m http.server 8000
- compiled 3.4 from source in order
- mostly with quite a few issues with 3.2 that comes with Debian stable
- worked out well with virtualenv while making sure pip is up to date
- including with numpy, scipy, matplotlib, ipython
- coverage.py
- fancier output
- debugging
python -m pdb mycode.py
(Pdb) break 68
set breakpoint at the line 68
(Pdb) c
continue until the next breakpoint
- allow to test for the different values interactively
- supybot-plugin-create : Supybot command to generate a plugin template (basic source and license)
Websites
- Django
- note that if working with Git and branches then the migrations and the DB in particular *have* to be tracked
- typical error else OperationalError
- working with Jupyter/notebooks
- models
- views
- templates
- key apps
- to find new apps
- Djangos requestresponse cycle a visual guide
Sysadmin
On going projects
Past projects
Principle
- read our current position on the log file (last successful writing in the wiki)
- if no current position, create it and start at 0
- read the log file from this position to the end of the file
- write the content in the wiki
- update the current position in the log file to the current end of file
- return an explicit value and quit
See also
References
To explore
Note
My notes on Tools gather what I know or want to know. Consequently they are not and will never be complete references. For this, official manuals and online communities provide much better answers.