Python Articles and Other Scribblings
Selected Writing and Ravings
From time to time I write something. Occasionally what I write will be worth reading. These are links to a few of the technical and python related articles I've written. It might include tutorials, rants, ideas, or anything else. If you're more interested in actual code, you probably want the Python Index Page, which has links to my Python modules, programs, and smaller "recipes".
|Voidspace Articles and Writing|
|IronPython||Articles on HTTP|
|Other Articles||Personal Writing|
IronPython in Action
I've written a book for Manning publications on programming with IronPython:
I've written up my wholly subjective experience of writing a technical book:
The Microsoft UK developer newsletter MSDN Flash, has published an article of mine on Getting Started with IronPython. This is one of their first experiments in publishing articles by non-Microsoft employees:
Programming with IronPython, Silverlight and Windows Forms
IronPython is a Microsoft implementation of Python, written in C#. It has full integration with the dotnet framework. Windows Forms is a great way of creating native looking applications using IronPython.
I have also written a series of articles on programming with Silverlight and IronPython (including online demos and examples to download):
The IronPython Cookbook
I've also started a Wiki with samples of using IronPython and the .NET framework. It includes over 100 examples of system administration, sending and receiving Udp, interoperating with the system, IronPython and Silverlight and lots more.
A Series of Tutorials
This is a series of articles on accessing HTTP from Python. The first one is a tutorial on the Python module urllib2. It covers fetching URLs, coping with errors, and using handlers and openers. It should be useful to anyone new to using urllib2.
The second explains the subject of BASIC authentication. It illustrates how authentication works, and then goes through a simpler example showing how to handle it properly ! If you need to fetch web pages from a server protected with Basic authentication , this will tell you what you need to know.
The third article is about handling cookies when fetching web pages. By default Python doesn't do this. In Python 2.4 a new module called cookielib has been added to the standard library. Prior to Python 2.4 it existed as ClientCookie. This article shows you how to use these modules to handle cookies automatically when fetching webpages from Python.
A Few Articles Related to Python
These articles are yet more writings on the subject of programming with Python.
A Python Programming Style Guide
I care about code quality. Code should be beautiful (elegant) and part of that means it needs to look beautiful. This is a rough guide to my own preferences in source code style for Python programming:
New and Improved: Coming changes to unittest
In Python 2.7 and 3.2 a whole bunch of improvements to unittest will arrive. unittest is the Python standard library testing framework and for several years it has languished whilst other Python testing frameworks have innovated. Some of the best innovations have made their way into unittest which has had quite a renovation.
This article goes through the major changes, like the new assert methods, test discovery and the load_tests protocol, and explains how they can be used with earlier versions of Python through the unittest2 module.
Introduction to Testing with unittest
An introduction to testing with the Python standard library testing framework unittest. As well as the basic API and principles the articles covers subjects like automatic test discovery and testing techniques like mock objects, monkey-patching and dependency injection.
Metaclasses in Five Minutes
Originally a lightning talk for PyCon UK 2008, this short article aims to explain the basic principles of metaclasses in just five minutes!
Python, Windows and the Command Line
This article is a tutorial on setting up a basic command line environment. It is aimed at new programmers who may not have used the command shell environment before. It conatins a few tips and tricks specific to Python, but should be useful to anyone who wants to use the Windows console.
An Introduction to ConfigObj
ConfigObj is an easy to use but powerful configuration file reader library. This article is an introduction to ConfigObj, and is a particularly useful reference on the config file validation features.
This article was originally published in the May 2008 issue of the Python Magazine. Many thanks to them for allowing me to reproduce it in full.
Porting mock to Python 3
The mock module now supports both Python 2 & 3. This article goes through all the changes and compatibility tricks needed to support Python 2.4 and 3.2 (and all versions in between) from a single codebase.
Functional Testing Desktop Applications
Writing GUI applications may be out of fashion, but if you do it make sure that you test them!
Since 2006 I've been working at Resolver Systems creating a desktop spreadsheet development environment called Resolver One. This article was originally a talk for PyCon UK based on my experiences of testing Resolver One.
- The why and how of functional testing - including the processes and infrastructure you need around them
- Basic principles of practical testing
- Common problems and ways to overcome them
The article includes a downloadable project with test framework - including example unit tests and functional tests. There is also a two minute video of the Resolver One automated test suite running.
Python and Rich Comparison
Python rich comparison has always annoyed me, at least having to provide all the rich comparison methods has always annoyed me. This article shows how CPython differs from IronPython in this respect. It also implements a 'rich comparison mixin' class, so that you can have all of them just by providing two methods (instead of six). There is an example of using it, along with full unit tests. (Which serve as a good example of using the unittest module if you haven't used it before.)
Introduction to Metaclasses
This brief tutorial will introduce you to the basic concept of metaclasses. It illustrates them with a metaclass that will automatically decorate all the methods in a class. This can be used to do really useful things like remove the need to explicitly declare self in methods.
Python Properties and C# 3.0 Language Features
An article exploring Python properties - comparing them to C#, looking at the new way of declaring them coming in Python 2.6 and an alternative method inspired by C#. This is followed by a look at some of the new features in C# 3.0 and whether Python has anything to learn from them (including a look at whether LINQ could work in Python):
Mocking, Patching, Stubbing: all that Stuff
An article on the subject of mocking, patching and stubbing in tests. It is also an introduction to the Mock class and the rational behind it.
An Introduction to Python and its Data-Types
A brief introduction to Python and it's basic data-types, which may one day become part of a tutorial. In the meantime it covers the different built-in data types and the Python syntax for them.
Object Oriented Programming
A Python and Objects Tutorial
An introduction to object oriented programming with Python. This article is for relative beginners to Python who would like to understand what Object Oriented programming is all about. It will introduce you to classes, as well as explaining the concepts behind them.
Exploring Dynamic Scoping in Python
An experimentation with Python code objects, bytecode and the Python scoping rules. (This article used to be called Anonymous Code Blocks in Python.)
It uses the excellent Byteplay module to explore Dynamic Scoping in Python. It results in a function called AnonymousCodeBlock. This can take a function and return a code object representing the function body. Local variables used by the function you passed in, and names bound by it, will be looked up and bound in the scope in which you execute the code.
Duck Typing in Python
This article starts with an introduction to typing, and finishes with a rant about duck typing. Specifically, it is a rant about how the poorly defined concepts of the Mapping Type and the Sequence Type make some kinds of duck typing impossible - and suggests a way round this.
Mapping and Sequence Type Reference
This is three pages from the Python documentation on the Mapping and Sequence type objects. A handy reference for anyone who has ever struggled to find the pages in the Python docs which tell you the special methods to implement.
Guessing Text Encodings
This is an article about how to guess the encoding for arbitrary text files. This is vital if you want to be able to correctly interpret or display text.
This article was prompted by a discussion of how Python 3000 will handle text, so you can quickly get up to speed on some of the ways that Python is evolving.
Data Persistence with ConfigObj
This is an article that describes how to use ConfigObj for data persistence. Storing and restoring data structures is a common problem for programmers and ConfigObj is suitable for many simple data persistence problems. This is especially true if a human readable format is an advantage . The article also provides tools for automatically creating 'configspecs', for config file validation.
Every eighteen months or so, a new version of Python comes out. They represent a lot of hard work, and in the case of Python 2.4 - a heck of a lot of arguing about decorator syntax.
I first started to learn Python about mid 2003, which meant the change from Python 2.2 to 2.3 had just happened. I think I did have Python 2.2 installed, maybe even for as long as several days !
Python 2.4 was the first time I really had to contend with a major version upgrade.
This article is about the problems associated with upgrading, the set of python modules that I actually use, and the difficulties of compiling C extension modules under windows.
Interviews and Recordings
As well as writing articles I've recorded various podcasts and interviews. These are mostly to do with IronPython, my book IronPython in Action and Resolver Systems:
The closest I've come to recording a podcast myself - four five minute Audio boo episodes on Python performance, implementations and books. Recorded in July 2009.
An interview with Randal Schwartz and Leo Laporte from August 2009.
From August 2009, several interviews from the EuroPython conference including one with me about IronPython, Ironclad and Resolver One.
Recorded April 2009.
Videos from an IronPython tutorial given by me and Jonathan Hartley at the US PyCon 2009 conference.
From April 2009.
Recorded March 2009.
Another interview recorded at TechEd 2007, with Dave and Rich from the NxtGenUG user group.
A five minute interview recorded at with me at Microsoft TechEd Europe 2007 about developing with IronPython.
Python 411 - An Interview with Ron Stephens
April 2nd 2006
This is an interview with me, by Ron Stephens, from his Python 411 Series.
It is about how I got into programming and started with Python.
A few of my articles have been published in PyZine - the online Python Journal.
A Crash Course in Character Encodings
The mere mention of Unicode can be enough to bring some programmers out in a sweat. Unfortunately the days of burying our heads in the sand and pretending that encodings are not an issue have long gone. If your program isn't aware of different encodings, then the chances are that many people can't use it.
Fortunately, Unicode in Python isn't as difficult as it's reputation. This article is a Unicode tutorial and will get you up to speed very quickly. At the time of writing it was free to read as well.
Python at Both Ends of the Web
This is a three part set of articles on using Python with the internet. The first part appeared in issue 7 - and is about writing web clients, programs that access the internet.
The second and third parts are about writing web applications, as Python CGIs. The first part of this appeared into issue 8, and is free to view.
The first part of this article is sometimes offline. You can view a cached version of this article at CGI Articles Part One.
The second part of the CGI article is available on Voidspace :
Articles in Other Languages
Several of the articles here have been translated into other languages.
French translations of the articles on working with HTTP and Python.
The articles were translated by Gerard Labadie and the HTML markup done by Thomas Labadie (11 years old).
There is a Portuguese translation (By Luiz Carlos Geron) and a French translation (By Gerard Labadie), of Object Oriented Programming with Python :
Object Shaped Future
Which Programming Paradigm Will Last ?
This article looks at modern programming languages, the ones we call high level languages, and whether they can last into the future of computer programming.
Stopping the Spammers
This article contains an interesting technique for stopping spam - all spam. This takes the war on spam to a new level. Instead of constantly battling to recognise spam, we increase the costs of sending spam tenfold - or even a hundredfold.
The article is a work in progress - I haven't yet written the code to implement the idea - but it might just work...
New Voidspace Manifesto
Voidspace was (is ?) a sprawling mess. Now this is possibly a fair reflection on my mindset, but it was impossible to maintain, took up too much bandwidth, and was suffering from a bad case of link rot. On top of all that the HTML was pretty awful. These python pages were the first converted over to an XHTML and CSS design.
This article was my attempt to decide how I should organise the revamp, and what tools I wanted.
The set of tools I envisaged have become a reality, in the form of rest2web.
Me, Myself and uhm...
Other Articles on Voidspace
Various articles on computing. These are hosted over in a different section of Voidspace, but are well worth a read.
An article with various tricks and tips on how to get unfiltered access to the World Wide Web, even behind a censoring firewall or blocking software.
A look at free and cheap and providers of phone calls across the internet. This article particularly looks at software for Linux and PocketPC devices.
The set of applications and utilities that I've come to rely on over the years. It also includes a list of the Firefox extensions that I use regularly.
This is actually an extract from a longer article. It gives a very brief history of different programming methods, including the moment that debugging was born.
A fantastic article by Neal Stephenson. I can't recommend this enough. It's about the history of operating systems and the paradigms they're built on. A balanced insight into the philosophy behind computer system design.
A clear explanation of some of the technologies and principles behind the internet. It's from 2000, but all still true - slightly updated to include a mention of firewalls.
A small article about some interesting events in 2002. How Slashdot got revenge on a "spam king". This is where virtual life intrudes on real life.
Ok, I admit it. I did write this one. It's an article on how to learn to write bad HTML very quickly. It is showing its age, but if you need to get a webpage up in a hurry it will show you how. Uses tables for layout.
You can read other blogs, and news on similar topics, over at Planet Voidspace. This is updated hourly, and has combined blogs on Cyberpunk, programming, humor and science.
|||In fact doing DIGEST authentication from Python is very similar to the second example and would only need slight modifications.|
|||I'm not trying to compete with YAML though.|
For buying techie books, science fiction, computer hardware or the latest gadgets: visit The Voidspace Amazon Store.
Last edited Tue Aug 2 00:51:34 2011.