Programming in Python
So I’ve mostly used python for one off scripts and tools and at one point for a serious foray into Django - but never came into a situation where I’d thought of publishing anything.
Hmm - crossed that bridge over this weekend - and its been a fun journey. I’m writing this post with what I wrote :)
Things I’ve picked up
Code
-
Better understanding into Python modules, classes and code organization for libraries.
-
http://mikegrouchy.com/blog/2012/05/be-pythonic-initpy.html[Be Pythonic: init.py]
-
-
Good unit tests
-
Mocking in python
Packaging
-
Packaging with
setup.py
-
pip
,setuptools
,easy_install
and their idiosyncracies -
Install a platform specific script
-
PyPI - registering and publishing
-
Tutorial One point to note - if you create the
.pypirc
manually, you will need to manually do apython setup.py register
. If you skip that,python setup.py sdist upload
will fail with a 403.
-
Testing
-
virtualenv
- this link -
Testing platform specific scripts installed with tools above
-
Coverage
Coding/Style/Syntax linting
-
pyflakes
,pylame
,pep8
and integration in Vim with Syntastic
What I really, really liked
-
That I didn’t miss a debugger
-
That tests were short and sweet
-
good code coverage out of the box
-
pip
-
Overall, how pleasant it was and how much I enjoyed it.
Where I had hiccups
-
Mocks in python were a little hard to debug/understand
-
Should have written the tests first - but it came as an afterthought after I decided to publish.
-
Finding good documentation on packaging - for ex:, its hard to find a good walkthrough of how to publish
Just putting finishing touches and a little polish for a v0.9 release. Basically this post itself is nothing but a test. Should be out with it in a day or two.