In order to make the code examples accessible to the widest possible audience I have written them using the Python 2 dialect. While I personally prefer Python 3, the older dialect is still more widely used and is the default in all the Linux distros I’ve used. I appear to be in a minority of people who prefer v3 although this is probably because I started on v3.1
I assume you have Python Win32 Extensions installed as it is used in a lot of posts. It is easy to see the examples which use these extensions at they have an import win32* at the top. If the example use any other non-standard module or library this will be explicitly mentioned along with a homepage.
If you are not using Python 3.4 I recommend you install pip (a package manager) to add modules. To do this first download the target get-pip.py and run it (or enter python get-pip.py from the command line). Full documentation for pip is available here. This will place pip.exe inside your Python installation’s Scripts folder. If this in not on your path you can run C:\PythonXX\Tools\Scripts\win_add2path.py to add it the path or change into C:\PythonXX\Scripts to run pip. Once pip has been installed you can test this by installing virtualenv by simply entering pip install virtualenv. Python 3.4 includes pip and virtualenv out of the box so there is no need.
Where the code fragments require a change in order for them to run on Python 3 (apart from the print command) there will be a comment on the line before with the necessary change or a warning. For the example programs supplied you can use 2to3.py to convert them. Run python 2to3.py -w example.py to make the changes. If you forget the -w it will not write the changes to the file and instead display them on the screen.
Talking of code I have attempted to keep with the recommendations in the PEP8 style guide with one noticeable exception for code fragments; multiple imports will be included on a single line. This is done to reduce space.
I have tried to test all example snippets and programs on 32bit Python 2.5, 64bit Python 2.7 and 64bit Python3.2 after running 2to3.py; if you spot any typos please let me know.
For several of the posts I have included an example program at the end to illustrate. I believe it would be distracting to include the code in the body of the post and then media options on WordPress do not cater for program code. As a result I have used BitBucket to host the program files. This allows each program to be viewed from the link and you can download an archive of all the current programs by clicking on the Get Source link.
I do recommend the use of Mercurial as a source control management tool. You can clone the entire repository straight from the BitBucket website; they even give you the command to do it. For Windows I use TortoiseHg which includes the command line tool and a GUI integrated into Windows explorer. There is even a manual if you have a couple of hours to learn.
Finally use the comments section if you think you’ve spotted a problem, want to ask a question or just generally leave a message. I try and regularly check the blog even if I don’t manage to post as often as I would like.