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

Multiple File Support in Docutils

emoticon:newspaper One thing that has limited the use of docutils (the project which gives us ReStructured Text markup) is its inability to handle multiple documents.

To link between documents you have to link to the specific output format (html and LaTeX are the most common, but there is also support for writing ODT documents and others), which means that you can't create cross-linked multi paged documents in a writer independent way.

You also can't use docutils to create table of contents for multi-paged documents, something that would be really useful for rest2web.

This might all change though. Lea Wiemann has a Google Summer of Code project to add multiple document support to docutils.

She [1] has already started, with a proposal for Multiple Input Files. This isn't the final answer (it doesn't support multiple output files, the holy grail), but it is an important step.

Along with the recent work to move the Python documentation to ReST format (which may or may not come to fruition - but the signs are good) and the debate on the docutils-develop list about adding syntax highlighting to docutils is really good news for documenting Python projects.

Whilst we're on the subject, at Resolver we are finally using the documentation tool I wrote last Christmas. The combined fix to code objects in IronPython 1.1 and the inspect patch in FePy means that it now runs under IronPython instead of having to use CPython. The nice thing was, that after porting to IronPython it pulled together docs from our modules straight away. We are using this rather than one of the other Python systems is that we want to heavily customize which parts of the API are documented and which aren't.

Resolver is going out to a range of beta customers over the next few days, so good API documentation is very important.

Oh, and important news: Brett Cannon has finished a secure version of Python. Sweet. Smile

[1]I'm assuming here, but it sounds like a female name to my uneducated English ears.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-31 22:04:24 | |

Categories: , ,


Movable Python to Go Open Source? Maybe...

emoticon:movpy2 Having Movable Python as a commercial product, rather than Open Source, has been an interesting experiment for me.

Movable Python started as an idea for testing standalone applications. I thought it would be nice to have a 'generic' standalone Python so that I didn't have to recompile scripts with py2exe every time I made a change I wanted to test. It also turned out to be really useful for a machine that I couldn't install Python on.

When I released the first version of Movable Python on sourceforge, it quickly had several thousand downloads and I spent quite a lot of time fixing problems that other people were finding. In all the time it was open source, and used by a lot of people, I only had one donation.

At the time I had lots of ideas for improving Movable Python, but was annoyed that so few people (who seemed to be using it) were prepared to contribute either there own time or any money for the effort I put in. Welcome to Open Source I guess. Smile

Since being a commercial product, Movable Python has been purchased by a few hundred people and I've enjoyed the feedback I've had from users. Unfortunately I'm not now able to devote as much time as I would like to the next round of improvements. It also seems that having Movable Python free would be good for the Python community, for example for creating generic PyGame executables.

What I have decided to do, is to release Movable Python as Open Source after the next 500 pounds worth of sales. That is either one hundred sales of a standard distribution, or thirty-nine mega-packs, or some combination of the two.

Additionally, 20% of the proceeds will be donated to the Python Software Foundation and 20% to the One Laptop Per Child project. After paypal fees, that will be about half the money.

I will release, subject to a BSD License:

  • The 'compiler', which allows you to build custom distributions
  • The source to the runtime and user interface
  • The pre-built distributions

So now, if you buy Movable Python you will be helping move it become open source as well as contributing to the PSF and OLPC. As well as being a good way of making some contribution to two worthy projects, it is also a nice way to bring this 'commercial phase' of Movable Python to a close.

Once it is Open Source, it should prove easier to port the compiler and runtime (much of which is portable - pun intended I'm afraid) to other platforms.

Movable Python can be purchased from:

On the vague offchance that anyone who already has Movable Python wishes to contribute, or you would like to donate more than the nominal cost, my PayPal address is:

michael@voidspace.org.uk

Smile

The reasons why I am not just releasing it as Open Source immediately include that it really has been a lot of work (their are a lot of workarounds in the runtime to fix issues) and I'm not currently using it, and also to try and avoid annoying those who have recently paid. So, if you are interested in trying Movable Python, you now have to make the trade-off of either contributing to its release, or waiting for it to happen anyway (which will probably be a few months and of course will take longer if you do that)...

Anyway, I'll keep you updated as to how it is going.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-31 14:30:00 | |

Categories: ,


IronPython Wiki Cookbook

emoticon:bluetooth One of the things I've been working on in my 'spare time':

This is a wiki with information about IronPython and code examples of how to achieve common tasks using IronPython and the .NET framework. There are links to my IronPython Articles (of course).

New code examples include:

There is a lot more to be done, but I hope this will be a useful resource for the IronPython community. Registration is required to create and edit pages, but if you have some useful examples of IronPython then please add them.

If there is anything you want to know how to do with IronPython, then the IronPython Mailing List is a great place to ask. Useful code that turns up there will hopefully end up on the Wiki too. Smile

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-30 16:34:59 | |

Categories: , ,


I Can Has LOL Code Now Plz

emoticon:apple Resolver has recently been hit by a bizarre fetish for lolcats. This is all the fault of Christian, but oh well.

Things get weirder though, today we discovered lolcode: I HAS 1337 CODE. LOL!!1

This takes the odd and cutsie language of the lolcats and turns it into executable code. For example:

HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
    UP VAR!!1
    VISIBLE VAR
    IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE

To make our world complete, someone has contributed a lolcode interpreter using Python and PLY (with interactive interpreter!): sjl7678's interpreter.

Stranger than a grasshopper's banjo...

(Oh, and this: Linux sponsored Indy 500 car comes in last - crashed due to driver problems!)

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-30 14:25:37 | |

Categories: , ,


Obscuring Email with Web-Form Fallback

emoticon:computer Everyone knows that putting plain email addresses into a web-page is asking for trouble. The spam-spiders roam the internet, hungry for fresh prey [1].

There are various options for obscuring email addresses, one option being to use a 'contact form' instead. On Delia's Translation Page I wanted to use real email address, but to obscure them as securely as possible.

The following HTML / Javascript combination (homebrew, so it's ugly I'm afraid) uses Javascript [2] to insert the email address. If the page is viewed without javascript, the links are to the contact form on this site; which isn't ideal but is fine as a fallback:

<ul>
    <li id="emailm">
<a href="http://www.voidspace.org.uk/cgi-bin/contact/contact.py">
Michael Foord</a></li>
    <li id="emaild">
<a href="http://www.voidspace.org.uk/cgi-bin/contact/contact.py">
Delia Foord</a></li>
</ul>


<script language="JavaScript" type="text/javascript" >
     //<![CDATA[
         <!-- Begin
         name1 = "Michael Foord";
         name2 = "Delia Foord";
         start = '<a href="mailto:';
         end = '</a>';
         thefirst = "michael";
         thesecond = "delia";
         middle = '&#37;&#52;&#48;theotherdelia&#46;co&#46;uk">';
         document.getElementById("emailm").innerHTML =  start +
             thefirst + middle + name1 + end;
         document.getElementById("emaild").innerHTML =  start +
             thesecond + middle + name2 + end;
         // End -->
     //]]>
 </script>
[1]I really should implement SpamTrap, although there are Similar projects around.
[2]I'm pretty sure that there aren't many bots (but it just takes one) with a full DOM and Javascript interpreter.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-28 20:07:29 | |

Categories: , ,


Import with Reload

emoticon:paper Often when developing a module I want to test it in an interactive environment whilst I'm working on it. reload only works with modules, which means that to use it you have to reference your objects as Package.Module.Name; which is a pain in the doo-dabs.

This function is a helper function that allows you import names from a module or package, with a reload.

def importWithReload(moduleName, names):
   mod = __import__(moduleName)
   components = moduleName.split('.')
   for comp in components[1:]:
       mod = getattr(mod, comp)
   mod = reload(mod)
   if isinstance(names, list):
       output = []
       for name in names:
           output.append(getattr(mod, name))
       return output
   return getattr(mod, names)

spam, eggs = importWithReload('Package.Module', ['spam', 'eggs'])

It takes a module name and either a single name or a list of names to import from it.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-27 22:33:39 | |

Categories: ,


IronPython URLs

emoticon:podcast There are some interesting articles and blog entries on IronPython that I've stumbled across recently:

They're all posted to IronPython-URLs, but I guess not all of you read it. Smile

Man, Firefox is a hog. It leaks memory like a sieve. I've been setting up a new site and it was behaving a bit sluggishly. It was using 512 mega-bytes of RAM, with nine tabs open. I closed it down and re-opened the same pages. It is now only using 158meg, which is still a fair chunk of memory.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2007-05-27 15:40:54 | |

Categories: ,


Hosted by Webfaction

Counter...