Python for the uninitiated developer
Several times over the past year I have needed to get a team member up to speed on python development, and I've found myself sending out the same email over and over, so I thought I would take a bit of time to formalize what's been useful for me so that it may benefit someone else.
Traditionally, I've found that the newsgroups usually recommend the book Dive into Python for people new to the programming language.
My personal feeling is that probably the first 6 chapters are probably critical, everything after that is a bonus.
I found a few screencasts that show what it's like to develop in python. There's lots of information here....
In particular I found these very useful....
#1 the virtual environment/paster. One of the biggest pain in the ass' in any language is managing dependencies you are developing against. But especially in python and ruby and perl and php.
So the goal of the virtual environment is to provide a sandbox for you to develop in that manages a set of libraries you develop against that is completely separate from your system python installation.
If you are developing on linux this is really handy, however it doesn't work too well on windows, but if you are developing on windows, you can't do anything without administrative rights anyway, so you pretty much own your python installation and it may be a non-issue.
The other tool discussed called paste has some nice features for creating python packages called eggs, which are cool because you declare what your dependencies are and there are other tools that will automatically pull them down and install them when your package is installed.
(ShowMeDo)Using Virtualenv and PasteScript
#2 unit testing with Nose, and Coverage. Good introduction to a really brain dead easy way to unit test.
(ShowMeDo)Using Nosetests and Coverage to create robust software
#3 an overview of sphinx which is a tool for generating documentation from your source code. the python dev team is actually moving to this for 2.6 and the 3.X series. It's a little new and so documentation on how to use it effectively is still a little light, but it's still the best option I could find.
(ShowMeDo)Using Sphinx and Doctests to provide robust documentation
For source code management, the trend now is leaning away from centralized and more towards distributed. There's a variety to choose from but the one I have become accustomed with is Mercurial because at the time that I was looking for a subversion replacement, it seemed to be the only one that worked on Windows out of the box. This might not be true now, but who cares. It works...nuff said. I constantly find myself referencing this book whenever I am trying some feature for the first time. it is an invaluable reference in my opinion.
Other than that, I find that using pythons easy_install system works a lot better than trying to track down installs of all the packages. All the cool python web stacks will install it for you, but if you want to install it first. http://peak.telecommunity.com/DevCenter/EasyInstall
Basically after it's installed you can install packages this way...
c:\>easy_install pylonsAnd it will fetch everything it needs from the internet to install a working pylons installation.
So usually when I'm setting up a python installation that is step 1.
Step 2 is pulling down all the stuff I typically use. c:\>easy_install ipython sqlalchemy mysql-python nose coverage sphinx And then whatever is relevant to whatever project I'm working on.
easy_install problem
c:\PortablePython\App\setuptools\command>python easy_install.py Traceback (most recent call last): File "easy_install.py", line 21, in <module> from setuptools.package_index import PackageIndex, parse_bdist_wininst File "C:\portablepython\App\setuptools\package_index.py", line 145, in <module > urllib2.__version__, require('setuptools')[0].version File "C:\portablepython\App\pkg_resources.py", line 626, in require needed = self.resolve(parse_requirements(requirements)) File "C:\portablepython\App\pkg_resources.py", line 524, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: setuptoolsHmmmm...
I don't have much experience with either of those other than reaching the same conclusions you did about both projects not seeming all that active.
My first stab at the problem would probably be upgrading setuptools and see what happens.
c:\easy_install -U setuptools
another thing you might want to try is see if urllib2 import properly. So in the python shell ....
>>>import urllib2
and see if you get any errors.
Post new comment