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

Firedrop 0.2.1

emoticon:firedrop2 There is a new release of Firedrop2. This is version 0.2.1, and is a bugfix release. Embarassed

Firedrop 0.2.1

This fixes two bugs :

  • Removed mistaken dependency on pythonutils
  • Fixed bug where cancelling the new site dialog would still report that the site was created

We also now have a written release procedure and a simple distribution builder script. These ought to make new releases simpler, and less error prone.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-30 22:40:47 | |

Categories: ,

Python 2.5 Excitement

emoticon:python Python 2.5 is nearly upon us. Just the Python bug day tomorrow [1], and then the trunk will be frozen for the first alpha release.

Python 2.5 includes several important additions. These include :

  • The controversial ternary operator [2], which allows syntax like a = 3 if b else 6.
  • the addition of the with keyword
  • extension of the generator protocol to allow all sorts of interesting things, including an approximation of the anonymous block feature beloved of Ruby advocates

Perhaps more important though are the additions to the standard library. The following modules (previously available as third party extensions) are slated for inclusion :

pysqlite has been approved for inclusion, but there is still some work to do, so it's possible that it will miss 2.5. These additions greatly increase the power of a standard Python install out of the box. Wow ! Smile

[1]Which I hope to participate in, dodgy wireless network permitting.
[2]Controversial because it harms readability; it's not immediately obvious what it does if you haven't seen it before. It's primary use case is to make list comprehensions more powerful. I am deeply in love with list comprehensions and so welcome this addition.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-30 11:24:24 | |


Obscure New Language Feature

emoticon:computer If you're interested in obscure new Python features, this might just make your day. Rolling Eyes

In Python 2.4 we acquired decorators for functions and methods. Guido resisted the few calling for class decorators, because there wasn't a clear use case that wasn't more readable done another way.

It turns out that certain .NET idioms in IronPython [1] would be best expressed with class decorators. On top of this, Greg Ewing found another use case - where the alternative was obscure metaclass jiggery pokery.

So Guido has conceded, class decorators will make it into some future version of Python; but probably not the imminent 2.5. It's nice to see that Guido is flexible in introducing features in Python that support the alternative implementations.

[1]And possibly Jython as well.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-29 13:42:41 | |


The Pain of Releasing

emoticon:tooth Pushing out a new release of any package is a painful procedure. The distribution needs packaging (which usually involves cleaning up your development version [1]), and it also needs testing. The docs also need checking and updating, then uploading and the announcements doing.

This whole process doesn't prevent embarrassing mistakes. Unfortunately I made such a mistake in the recent Firedrop2 release. Embarassed

It now uses ConfigObj for reading and writing config files. To avoid an extra dependency, I bundled in the distribution directory.

Sadly I forgot to modify the import statements to use the bundled one. As the two machines we test on (one Mac, one Windoze box) both have pythonutils installed we didn't pick up on this. sigh

Two things are clear :

  • We need a written release procedure.
  • I need a clean box for testing releases on, then I can test that releases work out of the box.

I'm due to move flat soon (possibly earlier than expected), so I'll hopefully have space to setup a spare box then.

My apologies to anyone that this 'bit'. If you downloaded Firedrop2 last night, then you either need to install pythonutils or download a fresh copy.

[1]This part at least can be automated. I have a convenient distribution builder script for rest2web, but not yet for Firedrop.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-27 16:01:06 | |

Categories: , ,

PyPy Produces Tangible Results (Well... Almost)

emoticon:exclaim I've long been interested in the PyPy project.

If my understanding is correct (which is by no means guaranteed), this project aims to create an experimental Python interpreter built with Python itself. The core uses a restricted subset of Python called RPython. The project is funded by the EU and aims at a better understanding of dynamic languages.

What makes the project even more intruiging is that working on it are Armin Rigo (the brains behind psyco) and Christian Tismer (the brains behind Stackless Python).

Despite this it hasn't been clear what the tangible results of PyPy will be [1]. The most clearly defined goal seems to be a JIT compiler to speed up execution of Python programs. Whether that would be compatible with CPython (like psyco is), or be an alternative implementation hasn't been clear.

RPython gains its speed advantage by being directly translatable into C. It ought then be possible to write code in RPython that can be automatically 'compiled' into efficient C. The PyPy team have (in the past) explicitly stated that this isn't a goal of the project, but would be a nice side effect if someone else would do the work in breaking out the RPython compiler from the rest of PyPy.

It looks like someone has just done that, or at least something similar. The following announcement was recently posted to the PyPy-dev List by Christian Tismer :

Dear friends,

this is just a greeting and short notice to a few of my friends. I am just so happy and relaxed and resolved, so I have to tell you.


PyPy is now able to compile efficient extension modules!


I'm going to write a larger article about this.


This is a spin-off of the PyPy project. See

All credentials must go to the group. I only found a way to make it accessible and usable in a pre-mature state. I'm just a member of this team, and I (ab)used the results of the project, to create something what every serious Python extension writer will love.

What is it good for?

You can write algorithms in an almost Pythonic language instead of using C. Your code will be translated into a C Python extension module of very high efficiency.


You will want to stop coding any C extensions by hand at all. Instead, you will produce series of extensions automagically and rank them by their performance, and then choose what fits your needs the best.


The module is not really available right now at all. The proof-of-concept implementation does exist as a test case, see

I'm going to do some refinements and optimizations quickly, and there will be a command-line tool that will produce extensions from a simple init script. I want to name this tool "raymond", after my good friend Raymond Hettinger if he doesn't mind.


I'd like to mention that this work was done on behalf of and inspired by EWT LLC, the company I'm currently consulting for. They are interested in using these short-term PyPy spin-offs to produce ultra-fast specialized modules, and they supported me in every possible way.


This relatively small addition should be perceived as an interim replacement for the final JIT-accelerated PyPy implementation which we all wish to instantiate at some time.

Until that happens, I think we can give the people a very nice tool to improve their productivity.


Right now, there is some level of indirection, since I use PyCObject to implement the wrappers. This will change pretty soon.

It is not planned to build chamaeleon objects, which are really both CPython and RPython objects. This would be a slowdown for typical applications. The real solution is to have objects with a single level of indirection. I will post an article about the layout of this during the weekend.

Conclusion, again:

I am so happy!

Now this sounds similar to Pyrex, which also allows you to write C extensions using a Python like syntax. Nonetheles, it is extremely interesting. Maybe PyPy isn't a waste of time after all. Wink

[1]Except perhaps the translating into Python of several C modules in the standard library. If nothing else this is useful for other implementations of Python like Jython and IronPython.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-27 11:01:36 | |

Categories: ,

Firedrop 0.2.0

emoticon:firedrop2 It has finally happened, the release of Firedrop 0.2.0.

The impatient can download the new release here :

Firedrop 0.2.0 (1.3mb)


The first time you run version 0.2.0 it will convert your weblog config file to the new format.

Firedrop2 is the Python blog client with a host of features. These include :

  • RSS feed generation
  • Categories
  • Automatic archive generation
  • A powerful set of plugins, including spell checker and emailer
  • Entries can be made in text, HTML, ReST, textile, sextile or markdown markup
  • HTML templating system and macros for all sorts of tricks
  • Built in FTP capability for uploading your blog to a server
  • Because it's written in Python, it is easy to extend Firedrop or create new plugins for it

This new release has been made possible by the hard work of Stewart Midwinter.

The changes and new features include :

  • Firedrop will now start up by opening a default site.
  • You can set the default site using the GUI.
  • Main file name changed to firedrop.pyw
  • ConfigObj is now used to edit all the config files.
  • Full support for all style elements (e.g. underline, bold) in four major markup formats: ReST, Sextile, Textile, Markdown (plus HTML).
  • New entries are created in a separate dialog that takes care of the markup.
  • Links are available to websites for the markup styles.
  • You can reset the app to a null site, and/or delete all entries.
  • You can force a full build of your site, or just update your site.
  • You can now create sites serving Article Collections or Items Lists (e.g. FAQs) in addition to Weblogs.
  • Firedrop2 now runs on Mac OS X and Linux in addition to Windows.
  • You can view logfile contents using the GUI.
  • Documentation has been updated to reflect these changes.

There is a roadmap for future releases on the Firedrop2 Trac Site.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-26 19:13:22 | |

Categories: , ,

Say Something Random

emoticon:pen_book I'm finding it hard to get motivated whilst I wait to start my new job.

I've just implemented a new macro for Firedrop2 which creates this blog. It picks a random emoticon to start entries with. Very Happy


This is a re-post of a blog entry I made last week. This time I've included the actual code. Razz

This has the nice side effect of being changed every time I rebuild the blog [1].

By the way, the new release of Firedrop2 will hopefully be tonight. This has a whole forest of new features thanks to the hard work of Stewart Midwinter.

There is something of a roadmap emerging for future releases as well, on the Firedrop2 Trac.

Anyway, this is the code for the Random Emoticon macro. As macros tend to be, it's very simple. You will need to edit the _emo_dir to point to the right location for your emoticons [2] :

_emo_dir = r'D:\Python Projects\Webstuff Python\Voidspace FTP Mirror\emoticons'
def random_emoticon():
    """Insert a random emoticon."""
    import random
    emos = [e[:-4] for e in os.listdir(_emo_dir) if e.endswith('.gif')]
    return emoticon(emos[int(random.random() * len(emos))])
ran_emo = random_emoticon

You then use this in your blog with either of the following macros :


Lovely !

[1]Only for entries that use that macro.
[2]You can download some of the ones I use at Voidspace from the Free Emoticon Pack.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-03-26 18:52:50 | |

Categories: , , ,

Hosted by Webfaction