mnot’s blog

Design depends largely on constraints.” — Charles Eames

Python Entries

Tuesday, 18 October 2005

XSLT for the Rest of the Web

I’ve raved before about how useful the XSLT document() function is, once you get used to it. However, the stars have to be aligned just so to use it; the Web site can’t use cookies for anything important, and the content you’re interested in has to be available in well-formed XML. While that’s all fine and good on some higher-plane, utopian, RESTful, stateless, DTD- and Schema- described, Cool URIish Web, it’s not the useful on the Web that most of...

this entry’s page (12 comments)

Monday, 5 September 2005

Feed History -04

Feed History draft -04 is out, with the only major change being the replacement of fh:stateful with fh:incremental, with corresponding changes throughout the document, to make the concepts a bit clearer. This revision also makes cardinality, relative URIs and white space handling more explicit, and adds an acknowledgements section as promised. On the implementation front, here’s a quick-n-dirty Python script that demonstrates reconstruction of an incremental feed (RSS or Atom); while it’s more prototype code than something you’d want...

this entry’s page (1 comment)

Monday, 29 August 2005

sparta.py 0.8

I’m happy to announce that version 0.8 of sparta, a simple API for RDF, is now available. As always, feedback and suggestions are appreciated. This revision requires rdflib 2.2.1, as the APIs sparta relied upon have changed. It also adds a new method on the factory, addAlias, that lets you bypass the prefix_localname convention for URIs that don’t map well to python tokens. See spartaTest.py for an example of its use. Thanks to Bill de hÓra for the suggestion...

this entry’s page (6 comments)

Thursday, 17 March 2005

Sparta.py 0.7

I’m happy to announce that version 0.7 of sparta.py, a simple API for RDF, is now available. As always, feedback and suggestions are appreciated. My goal for this release was to clean up cardinality. In particular, I wanted to make Sparta usable with the Atom OWL work that’s been going on. Unfortunately, it’s difficult to show — both because Atom is a moving target, and due to a few flaws in the stylesheet and model — but with a...

this entry’s page (2 comments)

Wednesday, 15 December 2004

text/python?

I’m thinking about whether it would be a good idea to have a media type for Python source files, call it “text/python.” The main benefit that I see to doing this is the definition of a fragment identifier syntax; i.e., what the bit after the ‘#’ refers to. This would allow URIs to point to specific functions and classes in Python source files, which would be very useful when documenting code. It would also allow some cool import tricks...

this entry’s page (9 comments)

Monday, 6 December 2004

Sparta.py 0.6: RDF (and RSS!) Made Easy

Based on feedback (thanks, John), it's now mapped to an object that implements a subset of the interface of sets.Set, and produces a full sets.Set when you call the copy() method. rdf:Seq is mapped to a list, joining rdf:List; this allows Sparta to work with RSS 1.0, along with other formats that use Seq. The factory takes an optional schema_store argument, so you can store schema hints for Spara separately, if you wish.

this entry’s page (1 comment)

Saturday, 21 August 2004

sparta.py 0.5: RDF made easy

Version 0.5 of sparta.py is now available; with this release, it's roughly feature-complete.

this entry’s page (1 comment)

Sunday, 8 August 2004

Resistance is Futile

Bill points out the inevitability of the Pythonification of the world. I couldn’t agree more; if you listen to the whispers in the halls, all of the old objections are falling away, and people are taking a serious look at dynamically typed languages. Here’s a little tip; rather than gnashing your teeth holding onto the remnants of big, old statically-typed, clumsily compiled languages, instead of flirting with halfway measures and Johnny-come-lately languages, stick with the real thing. Most of the...

this entry’s page (16 comments)

Saturday, 31 July 2004

The Whole Web in a Python Dictionary

A few days ago I blogged a straw-man API for client-side HTTP based on dictionaries. This turns out to be well-aligned with a project I’ve had on the back burner for a while; coming up with some Python APIs for HTTP that are usable, encourage good practice, and well-aligned with the specifications. So, a first prototype is now available, with three modules defined; http.message, which defines common constructs for HTTP messages and their payloads, http.status, which enumerates the defined HTTP...

this entry’s page (8 comments)

Monday, 26 July 2004

Dictionary as API?

From the Daily Python URL comes another noteworthy API for XML; XMLFragment. I haven’t tried it yet (it doesn’t appear to be separately available, hint, hint), but I like the look of it. There are two interesting things going on here. First of all, XMLFragment basically gives up on modelling the complexity of XML in the language, instead punting to XPath. I think that’s a reasonable choice; it’s arguably more intuitive and simple than anything you could do with an...

this entry’s page (6 comments)

Saturday, 15 May 2004

sparta.py 0.4: Data Binding for RDF in Python

After a short pause (OK, nearly three years), I’ve released version 0.4 of sparta.py. Sparta is a simple API for RDF that binds RDF nodes to Python objects and RDF arcs to attributes of those Python objects. As such, it can be considered a “data binding” from RDF to Python. For an example of its use, see spartaTest.py and its output. New in this Version This version is based on rdflib, which makes it much easier to install and simpler...

this entry’s page (4 comments)

Friday, 7 May 2004

XopParser.py 0.2

To help inform discussion of XOP (and to save Sam the trouble ;), I’ve put together a quick-and-dirty (we’re talking two hours) XOP parser in Python. It isn’t particularly efficient, nor is it well-tested or robust; it’s only to demonstrate how a XOP parser might behave. On the command line, it can regurgitate XOP Packages as XML 1.0 serialisations of the Infoset; mnot-laptop:~/Desktop> ./XopParser.py -t <?xml version="1.0" encoding="iso-8859-1"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xop="http://www.w3.org/2003/12/xop/include" xmlns:xop-mime="http://www.w3.org/2003/12/xop/mime"> <soap:Body> <m:data xmlns:m="http://example.org/stuff"> <m:photo xop-mime:content-type="image/png"> Ly8gYmluYXJ5IG9jdGV0cyBmb3IgcG5nCg= </m:photo> <m:sig...

this entry’s page

Tuesday, 20 April 2004

Sean’s Words of Wisdom

Sean McGrath always has carefully considered positions, and he hits it out of the ballpark with this one. A few thoughts; Eventually though, to fully realise RESTian SOA we need to get linguistic determinism working for us, not against us. To do that, we need to bake key SOA distributed computing concepts right into the language. Surely you mean that we should bake in REST, no? In the case of the all important concept of dynamic typing, this means we...

this entry’s page (1 comment)

Monday, 29 March 2004

Python Just Got a Whole Lot Cooler

OK, so I know they’ve been around for a while, but I haven’t really got into Python’s metaclasses until just now, because I’ve been… well… busy. This excellent presentation about them from the most recent PyCon woke me up to what they could do — which is just about anything. One of the goals is making more information in Python declarative. To me, this means things similar to (but more elegant than) JSR175; the only thing we’re missing now is...

this entry’s page

Tuesday, 10 February 2004

RSS.py, version 0.45

This minor revision fixes the “admin” namespace’s URI to agree with the feed validator and pretty much all other implementations. From the docs; This library provides tools for working with RSS feeds as data structures. The core is an RSS parser capable of understanding most RSS formats, and a serializer that produces RSS1.0. The RSS channel itself can be represented as any arbitrary data structure; two such structures are provided both as examples and to service common usage. This approach...

this entry’s page (1 comment)

Tuesday, 9 December 2003

Python for the CLR

IronPython is an implementation of Python for the CLR with some intriguing initial perf numbers. [ via Jeremy Hylton’s Weblog ] Shame I don’t have a Windows box where I could play with this… I got Virtual PC last week, but it’s too painfully slow to be usable....

this entry’s page (1 comment)

Creative Commons