Python Programming, news on the Voidspace Python Projects and all things techie.

Static Typing - in Music

emoticon:music Following on with the theme of taking the micky out of static typing [1], I've found the perfect band for those who love statically typed programming languages :

The Incredible Mouth Band

Actually one of my colleagues showed this to me, but it's still funny. Razz

[1]Don't take this too seriously Max. Wink

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-13 21:16:48 | |

Categories: ,

Python in the Corporate World

emoticon:pencil It looks like Joel Spolsky was right: Python Interview Questions

We've finally made it. Laughing

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-13 14:24:48 | |

Categories: , ,

Hard Drive Wisdom on Windows from Python Newsgroup

emoticon:world Every now and then you stumble across an unexpected nugget of wisdom on the Python newsgroup, comp.lang.python Wink

Did you know that the default setting for hard drives under Windows puts your data more at risk of data-loss than it need be ? (I can hear Nicola Larosa grinning already.)

Russell Warren and friends explain :

NTFS is a journaling filesystem :

A file system journal is used in order to guarantee the integrity of the file system itself (but not of each individual file). Systems using NTFS are known to have improved reliability compared to FAT file systems.

However, by default, hard drives have write-caching enabled. This means that in the event of a power failure data may not be written to disk.

You can verify this by going to the device manager, right click on the icon of your hard drives and select properties. Normally 'Optimize for Performance' is selected, which enables write caching. If you don't have a UPS or backup power source, you may want to disable this.

My apologies for the rash of short entries, normal service will be resumed whenever I can be bothered.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-11 21:10:45 | |


IronPython and Hashlib

emoticon:acrobat Seo Sanghyeon has been at it again. He has just wrapped hashlib for IronPython.

hashlib for IronPython

This module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (defined in FIPS 180-2) as well as RSA's MD5 algorithm.

Of the implementation Seo says :

In CPython 2.5, md5 and sha modules are implemented as a thin wrapper around this module. The same is true for FePy now.

You can read the source, but here are some technical details:

In CPython, hashlib is backed by OpenSSL. can create hash object by name, in contrast to static constructors like hashlib.md5. This is implemented by OpenSSL function EVP_get_digestbyname.

I have mapped this to HashAlgorithm.Create, which was an obvious choice. This can be used, for example, to load RIPEMD160 which doesn't have static constructor in hashlib.

Oh, by the way, I updated too, and you can see the usage there. hashlib import is conditionalized to make it run on CPython 2.4 too.

Mono.Security.dll implements the SHA224 algorithm. This assembly is always included with Mono (as many security tools depends on it). The same assembly/binary can also be used on the MS runtime without any problems. (Now included in FePy.)

Very cool, but although FePy is a clever name, it isn't easy to say without it sounding faintly girly. Hmmm... Rolling Eyes

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-11 21:01:36 | |

Categories: ,

Some Things You Just Have to Share

emoticon:exclaim The problem with geek jokes is that can be very hard to find someone to share them with. Luckily that has been much easier since I started work at Resolver, but I also have this blog. Smile

Donald Knuth gets slightly annoyed

If you've not come across xkcd before, they can be very funny.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-11 20:30:31 | |

Categories: ,

IronPython Version Info

emoticon:world How does an IronPython program tell which version of IronPython it is running ?

Lots of code uses sys.version and sys.version_info to determine availability of Python features so changing that seems like a bad idea.

Also, the IronPython dlls are signed. So in order to allow updated dlls to be 'drop in replacements', the IronPython team keep the same assembly version between different releases.

So in 1.0.1 they added some assembly level attributes. This means that (currently) the official way to tell from code which version of IronPython you're running on, looks like this :

import System
attribute = System.Reflection.AssemblyFileVersionAttribute
dotnetType = [].GetType()
a = dotnetType.Assembly.GetCustomAttributes(attribute, False)
if len(a) > 0:
    if a[0].Version == "1.0.61005.1977":
        print "IronPython 1.0.1"
        print "Unknown version"
    print "IronPython 1.0"

Yeeurgh. Laughing

I hope they add a new attribute to sys, or some other sensible solution.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-10 20:34:18 | |

Categories: , ,

Jan Szumiec: May he Blog in Peace

emoticon:file1 Sorry for the obscure title, it's been a long day. Added to which I've just got home to discover that our front door has mysteriously dead-locked itself and I had to break in. Luckily I met my new neighbours in the dead of night last week, so they recognised me and let me round the back of the house. sigh

Anyway, Jan Szumiec (one of our summer interns at Resolver [1]) has just gone back to Poland. Despite his penchant for Ruby and Smalltalk, he is a clever guy and we will miss him. If he doesn't come over to work for us again at Christmas, I'll catch up with him at the RuPy Conference (Ruby and Python) in Poznan next April.

I've been meaning to link to his blog RubyRed for a while now, so there you go. As you can read from his recent entries, his experience at Resolver has thoroughly converted him to the merits of test driven development. Razz

I read somewhere a plausible explanation of why Python and Ruby are such contentious bedfellows (which makes the RuPy conference all the more interesting IMHO). It's because they are so similar. Competition is the fiercest between organisms that share the same evolutionary (or environmental) niche. Because Ruby and Python are both good for a similar range of tasks, they compete for mindshare and programmers. Smile

Luckily Python is well established in areas other than web development, so even it really does 'lose' to Ruby it isn't going to go away. phew

Two other pieces of unrelated news to shoehorn into this post.

  • There is a new blog aggregation called London Python. This is a Planet collection of London and UK Python bloggers.
  • The Python 'trunk' has just been frozen for a new release in the next few hours. This will Python 2.4.4, which ports many of the bugfixes incorporated into Python 2.5 back to Python 2.4.

Oh, and my contact form is now fixed and my atom feed is broken. Use the RSS Feed anyway. Smile

[1]Yes the website is going to get a makeover, 'real soon now' to channel my boss.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-10 18:46:41 | |

Categories: , , ,

New Things with IronPython

emoticon:ghostradio IronPython 1.0.1 is now out. One of the new features is that it now supports new 'builtins' through 'external' assemblies (dlls).

Mark Rees has a good article illustrating this feature with the md5 module.

Tangible Software Solutions also have a new product out :

Instant Python

This is a VB.NET to IronPython translator. I have a copy to play with, so if anyone can suggest a good project to experiment on with it, I'd love to hear about it.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-10 16:18:19 | |

Categories: ,

rest2web Man Page

emoticon:nightmare I'm trying to push out a new release of rest2web this week, hopefully in time to get it into the forthcoming release of Debian.

There are a few outstanding issues and some easy feature requests that I can complete, but finalising the documentation updates for 0.5.0 final. Smile

The fly in the ointment is that I won't have time to create a manpage for rest2web, which is needed for inclusion in Debian. I can write the text necessary, but don't have the time to learn a markup format and prepare it in time.

Is there anyone who might be able to do this for me, if I create the 'content' ?

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-10 15:13:35 | |

Categories: , ,

Agile Development & Religious Wars

emoticon:waffle Sometime ago Joel Spolsky linked to some guy's blog entry that was knocking Agile Development as a fad, or something like that. I didn't pay much attention, because Joel doesn't seem to think that functional testing is even possible so I doubt he has much sensible to say on the subject (or by implication is capable of linking to anything sensible...).

Anyway, it turns out that Steve Yegge was probably just saying that it has become another religious war. I still haven't read the original post, but because I have too many things to do and need a distraction, I skimmed his latest entry.

I can't tell you much about it, but there are two parts that are really funny.

Firstly (talking about the Perl Haiku Competition) :

I tried it with Java once, and produced a valid Java haiku:

ArrayList<int> myListOfInt = new ArrayList<int>();

which, spoken aloud, reads:

ArrayList of Int
my list of int, equals new
ArrayList of Int

Maybe it's just me, but I find it pretty farging depressing that a simple declaration like that can be haiku-sized in Java.

Secondly, he talks about static type systems :

The noted Far Side cartoonist and computer scientist Dr. Gary Larson published the definitive paper on Java-style static type systems in October 1987. [...] Here's Dr. Larson's renowned treatise on non-inferring static type systems:

A Funny Gary Larson Cartoon

Very funny. Mind you, having read a bit more of his post in the process of typing this up, it would appear that it is a crock of horse manure. I can't really tell as he doesn't seem to define 'agile methodologies' at all in the bits I've read, so I don't really know what he's talking about.

If he's just saying that religious wars are dumb, then I think I agree with him.

I now work with a company that use a whole raft of 'agile development' techniques. It's great. The process is fun, pair programming means you're less distracted so you produce more, and the code quality is great. I now use the relevant parts for my own projects (TDD etc), where possible, because I can see that it produces better code. In my experience these techniques are better than the alternatives I've seen. That's just my experience though.

It reminds me of the whole virulent creationist versus virulent anti-creationist thing. I'm a christian (if I don't put a capital C am I being blasphemous or something ? I just don't know these things). That whole debate is utterly irrelevant to me, as are most theological debates and arguments. My own faith is based on experience of God and relationship with him (I'm pretty sure that capital-G is right), so arguing about it is pretty damn pointless in my book. I'm not into proving God to people, but if they're up for it I enjoy helping them experience God [1]. Oh, and on the creationist thing, I think that I think that something a bit like intelligent design is probably right. But I don't really care, it's not the cornerstone of my faith. Smile

[1]For those who may be interested, I just made a post which is vaguely about the substance of my faith on my personal blog.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-09 21:55:02 | |

Categories: ,

Devil in the Detail

emoticon:boxing_gloves You can always tell a sloppily written program. When something goes wrong, you will get a helpful error dialog (if you're lucky) saying something like :

An Error Has Occurred

This morning, Christian and I have been adding some nice straightforward functionality to Resolver, at the tail end of a fun User Story. It may be straightforward, but as ever, the devil is in the detail.

There are lots of different ways this feature can fail, depending on exactly which permutation of munged input our user provides. We're going through and catching all of them, and providing sensible error messages. I'm feeling the pull of the dark side, but have so far managed to resist the An Error Has Occurred dialog. Smile

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-09 14:59:18 | |

Categories: ,

Is CGI Dead ?

emoticon:film With the recent rise of web frameworks, like Ruby on Rails, Django, Turbogears and friends, it might be fair to assume that the old workhorse CGI can be put out to pasture.

Well as recently as July [1], Bruce Eckel blogged about Testing Python CGIs.

CGI is a simple protocol that describes how a webserver passes http requests to a program, and how that program makes a response.

The beauty of CGI is it's simplicity. Most of the request [2] is passed on stdin, and the program passes a response back to the server on stdout.

The Python CGI Module makes understanding http requests very easy. To send a response, write to stdout.

CGI is still a very good way of connecting simple programs to the web. It's also a great way of cutting your teeth with web programming, particularly learning about http. In fact WSGI (the new Python protocol that aims to allow components in a webstack to communicate) aims to be a modern evolution of CGI.

Quite sophisticated programs can be written as CGIs, but they are more inefficient than modern web frameworks, as each request is handled by a separate Python process.

I've hacked around with a few CGIs of my own. I've also written a couple of tutorials, if you're interested in learning :

[1]Ok, so I'm a bit late with this entry. Smile
[2]But not authentication headers unfortunately.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-08 19:07:24 | |

Categories: ,

Zlib for IronPython

emoticon:black_hat Seo Sanghyeon has just announced that he has implemented zlib for IronPython (based on work by Mathieu Fenniak).

zlib for IronPython

Here is what he has to say about the implementation :

Done:adler32, compress, decompress
TODO:crc32, compressobj, decompressobj

At first I was confused because data compressed with Mathieu's code couldn't be decompressed with CPython's zlib module and vice versa.

People on #mono channel helped me. They told me .NET's DeflateStream is "bare" in that it doesn't generate nor accept ZLIB header and footer as defined in RFC 1950. So after reading the spec, I just wrote that part myself.

It still doesn't generate identical output, but compress/decompress in any mix of CPython/IronPython seem to work. I didn't test the code on Windows yet, so I'd appreciate your comments.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-08 19:01:50 | |

Categories: ,

Movable IDLE

emoticon:dove There is now an experimental version of Movable IDLE available, this is an off-shoot of the Movable Python project.

Movable IDLE, version 0.1.0 can be downloaded (free) from :

Movable IDLE Download

(Same place as the trial version of Movable Python.)

Movable IDLE is a portable distribution of IDLE, the Python IDE, for Windows.

This can be run without installing, and at only fifteen megabytes uncompressed it can be run from a USB stick or memory card.

It comes with the full Python standard library, and should be capable of running almost any program that can be run with IDLE. Hopefully this will be useful for educational and experimental purposes.

Movable IDLE doesn't yet have a homepage. This will be part of the new Movable Python docs, which I'm still writing. Smile


Movable IDLE does not have all the clever trickery that Movable Python does. This means that the win32 extensions, or any program that uses imp.find_module are unlikely to work. It also won't work with programs that have another event loop, like other GUI toolkits.

If you need these features, try Movable Python. Smile

On the other hand, if you do find bugs or restrictions, post them to the Movable Python Mailing List and it may be possible to fix them. This is the right place to post feedback and suggestions as well.


Movable IDLE is copyright Michael Foord, 2006. It is free, but not Open Source.

You are free to copy and distribute Movable IDLE, but not to charge for it. It may not be included in any distribution which charges directly or indirectly, without express permission.

The following sections of the Movable Python License also apply :

  • Disclaimer
  • Limitations
  • Restricted Uses


I forgot to mention that this was originally inspired by an email from Calvin Spealman.

In case the version number doesn't make it clear, this is 'experimental'. I'll fix any problems that arise (assuming I can fix them).

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-08 17:44:10 | |

Categories: ,

Voidspace Server Move

emoticon:newspaper After sticking with the same host for around a year (almost a record for Voidspace I think), I've changed server again. Smile

I've moved to Webfaction, the hosting company run by Remi who created CherryPy.

Instead of having root login on my own virtual server, I now have a Shared-2 Account. Although technically I can do less with this account than I could before, I don't have to maintain my own server. On top of this, deploying dynamic applications from Webfaction looks very easy. At some point in the next ten years I hope to find time to play with Django or Turbogears. Wink

Setting everything up was pretty straightforward (with a bit of help from Remi), for the several domains and email addresses I've moved over there. The only hiccup was a bit of time trying to work out how to point both and to point to the same place. Realising that the list of subdomains in the 'website' part of the control panel supported multi-selection was a big help.

I had some fun with my CGI scripts. It seems that Apache running CGIs with SuExec is pretty finicky about permissions. Additionally, the Webfaction servers don't have sendmail. I've changed a lot of my scripts to use smtp [1] rather than sendmail (resulting in a minor bugfix to my contact form CGI).

Unfortunately I still have an authentication problem. Razz

Changing server always causes problems, so I've come off quite lightly. Currently my contact form is down and I lost a few days worth of stats on my page views. Not too bad.

[1]They use cgiutils, which has code very similar to the example show in the Webfaction email FAQ.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-10-07 16:01:36 | |

Categories: , ,

Hosted by Webfaction