alan little’s weblog archive for october 2003

yoga links

31st October 2003 permanent link

I’ve updated my yoga links page - mostly just reformatting it to my super new-model weblog look, but also added a couple of new links:

Anne-Marie Newland and I are practically cousins - our families are very close, but we hadn’t actually been in touch for years until we discovered that we’re both now into yoga. She started out as a sivananda teacher (the real sort, studied in India with Devananda, not the one month “teacher training” sort) and now teaches a kind of sivananda-vinyasa fusion style. I went to one of her classes the last time I went home to visit my folks, and had a great time.

… whereas I’ve never actually met this guy, but I’d like to. John has been one of the good guys in the online yoga scene for years under the nom de plume “okrgr”. (I’ve never been able to get into online pseudonyms myself. Just too literal-minded). How he has a weblog, Days in my Lives.

God how boring. Don't I have anything more interesting to write about than maintaining my own website? Not really. Sorry. Or to put it another way, yes, lots of things, but they all require more thinking and writing time than half an hour on the train to work, so they get written slowly if at all.

And furthermore, if somebody is going to find their own Authentic Voice as a writer, everybody says they need to write stuff than comes from their Own Reality. My Reality these days features: maintaining my own website, maintaining other people's financial software, maintaining my son's various input and output processes. And not much else. Maybe, rarely, the odd half hour to actually spend together with Maria doing something other than preparing bottles or changing nappies. Maybe, rarely, the odd half hour for actual yoga practice. So what am I supposed to write about?

related entries: Yoga

photoshop 8

31st October 2003 permanent link

Photoshop 8 is out, with support for 16 bit layers that may or may not be useful. I think it looks worth getting anyway, but I'm not exactly delighted that Adobe are following US software companies’ usual policy of blatantly ripping off foreigners. The upgrade from Photoshop 7 to Photoshop 8 is listed on at $169.99. It’s worth it, there’s a lot of good stuff in there including one of the better converters on the market for raw files from digital cameras, which used to cost $99 on its own as an add-on to Photoshop 7.

But Adobe’s US online store will only ship to the US. I don’t want to risk getting a German language only version from, so I look at their UK site. £139.99. WHAT? That’s 238 dollars. Now, quoted retail prices in Europe always include sales tax and in the US they don’t, so let’s add UK sales tax at 17.5% for a fair comparison, and $169.99 becomes $198. The residual “blatantly rip foreigners off” factor is still $40, or almost 25% of the price of the product. Bastards. Sod ’em. $40 isn’t a fortune, but it’s the principle of the thing. I’ll wait until my graphic designer friend in New York pays a visit and get him to bring a copy over. Or I could ask our next Russian visitor to pick up a pirate copy in Moscow - Adobe, I’m willing to buy a legitimate copy of your product at a fair price, but I’m not happy about being overcharged 25% just because I don’t happen to live in America.

related entries: Photography

breathtakingly beautiful

28th October 2003 permanent link

I find this picture, by Canadian artist Lawren Harris, breathtakingly beautiful.

North Shore lake Superior

That in itself would be a good enough reason to post if, even if it weren’t for the fact that I’m also testing a function that turns the background image in my stylesheet off if the top weblog posting also has an image in it (otherwise the image in the posting superimposed on the background image looks stupid. Apart from which I’m very pleased with my new legible font plus background image look).

Picture courtesy of 2 Blowhards

related entries: Photography

panther - not

28th October 2003 permanent link

Hmm. Lots of people are enthusiastic about Apple's operating system upgrade, Mac OS X 10.3 "Panther", released at the weekend with much fanfare. However, it apparently fries external firewire drives and doesn't run ImagePrint. I'm rather fond of (a) having the 80GB of pictures that are backed up on my external firewire drive, and (b) being able to print them, so I think I'll be waiting a while before I think about upgrading.

related entries: Mac

but what is art, asked alice

24th October 2003 permanent link

I’m not normally in the habit of writing weblog entries saying “excellent posting by so and so, go and read it”, but now and again it can’t do any harm. Particularly when it’s as excellent as Alice Bachini’s deep philosophising on an Exhibition of Mediaeval “Art” at the V&A and what is art anyway? Was it in the middle ages what certain “high art” cliques have defined it as in the last couple of hundred years? (No). Is it what goes on in self-described “art galleries”, and is what goes on outside ”art galleries” not it? (No).

Quote from Alice:

So instead of asking ourselves, “But is it art?” we should be asking ourselves, “But is it any good ?” The Gothic knick-knacks I saw at the weekend were mostly very appealing. But this is 2003; we can do better. And I for one believe we are, and not just inside art galleries either

The comment I left:

You’re right. The idea that there is something that is Art-with-a-capital-A that exists on a different and somehow more elevated plane than grubby things like entertaining the masses, or making useful everyday things look pleasing, is and always has been utter garbage. It is a piece of romantic idealism that has poisoned people's minds for the last two hundred years and is hopefully now on the way out.

I can see no grounds at all for suggesting that things that actually do entertain the masses like, say, cinema or non-classical music or industrial design aren’t “art”, whereas things that were once wonderful but are now irrelevant dead genres, like literary novels or classical music, are. Anybody who can write a “History of Art” that covers the twentieth century without even mentioning photography or cinema is obviously an ignorant pretentious tosser. (Oops, Paul Johnson did)

Have been meaning to write something about this for a while but it's sitting in the “perpetually-unfinished profound stuff” pile. Whereas the stuff that actually makes it into my weblog mostly comes from the “quick throwaway things that I can bash out in half an hour on the train to work” bucket. Need to learn how to bash out profundity in half an hour.

related entries: Photography

meanwhile, over on emusic

24th October 2003 permanent link

So I’m unimpressed with what I can glean about Apple’s music download service. Meanwhile over on eMusic, it’s download frenzy time for Alan. This triggered by the following observations:

(Fortunately my ISP just increased the monthly limit on my DSL account. Must write nice things about them some time soon)

So, what can you get from eMusic? Loads of interesting stuff. Vast archives of early blues (though not, sadly, the Robert Johnson recordings that I think I still have on vinyl in an attic somewhere in England. Pity I don't have a turntable any more). Huge amounts of jazz. I’m not a big jazz fan, but it can’t do any harm to have a few Charlie Parker tunes lying around in case I ever do get the urge. Quite a bit of ’60s soul and gospel. A smallish selection of western classical music - mostly obscure stuff but some potential gems. (Currently downloading an Alfred Brendel recording of Beethoven’s Hammerklavier sonata). An even smaller selection of Indian classical music, but some of it must be worth listening to. And vast amounts of modern American and British indie stuff, most of which isn’t of much interest to me but presumably is to some people.

Kimbro is massively pissed off that eMusic have decided to limit subscribers to 40 downloads a month for $10, or 60 for $15. I can understand why, if he's been used to downloading unlimited amounts for the same price. But I can also see how eMusic would need something approaching a viable business model, and their old terms & conditions can hardly have been one of those. It costs money to have people like Kimbro slurping away at your server at a rate of gigabytes a month. 25 cents a track is a reasonable price for an mp3 file. A dollar a track as charged by Apple and others is overpriced - near-CD price for not (even) near CD quality.

Inferior sound quality is an assumption based on what what stereophile magazine and this guy have to say about the audio quality of the iPod and various levels of mp3 and AAC encoding. If and when I ever get the chance to actually download an AAC file from iTMS and listen to it for myself, I will. Meanwhile I definitely intend to sit down some time soon and have a comparative listen to some variable bit rate mp3s from eMusic against CDs of the same things and draw my own conclusions. Problem being that I have no means of injecting mp3s into my real stereo at the moment, and everything sounds crap anyway on my iBook’s headphone socket.

UPDATE: I tried a comparative listen to a few things on my iBook anyway, since it's the only device I have at the moment that can play mp3s and CDs. Result: everything on the iBook sounds flat and lifeless. MP3s from eMusic possibly sound even more flat and lifeless than CDs - this was my opinion, also the opinion of a colleague who I subjected to a blind listening test. Not exactly conclusive, but not promising for online music actually being worth the money either.

related entries: Mac Music

itunes (still) not much music store?

22nd October 2003 permanent link

There’s a discussion going on at arstechnica regarding some people’s opinion that, unless you have very mainstream and boring musical tastes, you ain’t going to find much to your liking at the Apple’s iTunes Music Store. Which was also my impression when I had a look a while ago.

(I also particularly liked the guy who said that if Apple had his favourite music available, they would be deluged with emails from people complaining about corrupted files)

People say it’s getting better. I can’t check on this because, after letting me in once for a look round, it now says I’m not in the USA and refuses to even let me press my nose against the window. (Maybe I’ve been specifically , personally IP-banned for writing unimpressed things about it)

So let’s see: severe lack of interesting music. Near-CD prices for probably inferior to CD sound quality. CD prices for stuff I’m interested in, especially classical, are in free-fall. So I really can’t see what good iTMS going to be to me except for the odd one-hit wonder where I’m not interested in shelling out for a whole CD. And then, only if they actually have the one-hit wonders I want. And if they start selling them in Europe some time this decade. But then I’m not the target demographic anyway.

related entries: Music Mac

confusing style sheets

20th October 2003 permanent link

These days I’m trying to produce everything new for in standards-compliant xhtml and css, and maybe even gradually migrate some of the older bits. When it works it's nice, such as the recent changes in the layout of the weblog - mostly done by editing one stylesheet, plus a few tweaks to the xhtml templates that I use to generate the site. No touching of content files required. Some days it even passes validation.

Valid XHTML 1.0!

At the moment, though, I’m trying make what should be some simple layout changes to a photo gallery page, and (re)discovering that trying to get css to do what you want it to when it's not in a co-operative mood is a bizarre nightmare that, to quote the mighty Lileks, “makes you feel as though you're playing chess in the dark with oven mitts”. The temptation to just stick everything in tables and damn the future is overwhelming.

the day i sold guitar strings to the clash

16th October 2003 permanent link

I was thinking the other day about job insecurity in the software industry (and every other industry), and drifted from there onto reminiscing about other jobs I did before I was in software - mostly part time things when I was a student.

I was a Christmas postman several times, and in the summers I mostly did warehouse jobs. Warehouse work was good because it was physically hard and generally only came a few days at a time. I was big into rock climbing in those days, so having plenty of time to go climbing between spells of getting paid to do weight training was great.

The best warehouse job was the summer I worked for a guy from my local climbing club, who was a publisher of climbing books. Whenever he had a big order or a stock-take, Ken would round up a couple of the lads from the climbing club and pay us to lug boxes of books around for a few days. The working hours - the working days, in fact - were flexible. Ken was amenable to labour negotiation tactics like “er, Ken, the sun’s shining …”, to which if he was in a good mood and the job in hand wasn’t too desperately urgent, he would reply “ok, but I need you back by Thursday”, and off we would hitch to North Wales or the Peak District to go climbing for a day or two. Ken didn’t need ladders or fork-lift trucks (or health & safety regulations) in his warehouse - we positively enjoyed clambering up wobbly piles of boxes, and the more weight training we got paid to do, the happier we were.

Then there was the Saturday job I had in a music shop, for which I was spectacularly unqualified as the only member of my family who can’t read music - my brother and sister were in one of the country’s top youth orchestras at the time. The only real highlight of the job was The Day I Sold Guitar Strings To The Clash. Imagine: (a) this would have been circa 1978, when The Clash were one of the two or three top live bands in Britain (there are those who believe The Clash were one of the two or three top live rock bands of all time, anywhere), and their idea of a fun Saturday afternoon before a gig was to go out together into whatever boring little provincial town they happened to be playing that evening (Leicester) and look for a music shop where they could buy guitar strings; and (b) this was the only thing I ever did that even faintly impressed the punk chick in the record section upstairs, on whom I had a major crush, and whose name I can’t even remember a quarter of a century later. Possibly Claire.

related entries: Music

paul brunton reprise

10th October 2003 permanent link

Norman Blair responded to my previous mention of 1930s yoga researcher Paul Brunton with an interesting pointer to and quote from Jeffrey Masson’s book My Father’s Guru: A Journey Through Spirituality and Disillusion. Reviewers on Amazon have mixed views on whether the book is well enough written to be worth reading, but apparently pretty unmixed views on its debunking of Brunton.

i wish pb had been the person we all thought he was...pb offered wisdom, not knowledge, divine love, not human regard, visions, not insight, access to secret forces, not meditation, magic powers, not peruasion, mystery, secrecy, obfuscation, and must obey the guru, you must humble yourself, for the greater he is, the lesser you are - until you too reach the inner circle and can start abusing other people the way your guru abused you. all of this is in the very nature of being a for pb, i can’t find it in my heart to hate him, or even to despise him. i am still left with the mystery of a human being who is more than the sum of his ignorance and his pretense....he brough solace and joy to many by making claims that were not true

related entries: Yoga

public service announcement

8th October 2003 permanent link

I've noticed that the font I use for my weblog (which I specify in my stylesheet as Garamond or Georgia) looks great in Safari, and just-about-readable-but-spidery-&-nasty in everything else (where “everything else” means, to a first approximation, Internet Explorer and Mozilla). Now, despite the the fact that I know everybody would be much happier if they bought Macs and used Safari, I also know the world is unlikely to change to any significant degree just to suit my wishes & beliefs. 90% of the people reading are using Internet Explorer, and I will be doing some experimentation to find a font that looks ok for them too.

press release

6th October 2003 permanent link

Alan’s weblog now has an RSS feed – another triumph for the power of python and Alan’s super-sophisticated five line templating engine.

The feed looks ok in NetNewsWire Lite and has survived a pass through If anybody has any problems with it despite this rigorous quality control process, I’d be grateful to hear about them.

And more joy of python: converting all relative links (including images) to absolute links so as to remove a potential source of confusion for newsreaders. Four lines, ten minutes:

attribsToConvert = {'a':'href', 'img':'src'}
for k in attribsToConvert.keys() :
    for e in xmlText.getElementsByTagName(k) :
        e.setAttribute(attribsToConvert[k], \
            urlparse.urljoin(baseURL, \
        # urljoin does nothing if the url is already absolute

related entries: Programming

internet explorer on the increase

4th October 2003 permanent link

Internet Explorer on the increase again. Oh dear.

I started this weblog in July with a look at what browsers visitors to were using. The interesting bits, for me as a Mac user, were that I was getting around 10% of my page views from Mac users, which is higher than the installed base of Macs would suggest; and among Mac browsers, Safari was already at 15% market share and rising fast. Now let’s update that picture:

mac browser market share

Safari’s meteoric rise continued to around 23% in August but Netscape 4 rose too(Netscape 4? That’s even worse than IE). Then in September - Safari back below 20%, Internet Explorer up over 10%. What happened?

Well, we’re not exactly dealing with statistically significant trends here. That IE increase represents a little over 200 page views. It could mean I picked up a grand total of one enthusiastic Mac IE using reader who looked at every page on the site. (And if you’re reading this - get Safari, it’s much better) Don’t get alarmed by changes on percentage graphs until you’ve asked, percentages of what?

related entries: Mac

more beauty of python

3rd October 2003 permanent link

Time to add archiving to AYAWT, two hours: one hour in the evening after putting the baby to bed to sketch out the basic concept and object model; one hour in the morning before work to test & debug.

It’s amazing how good programming languages & tools are getting these days. I can have a family, a day job, a life - and still, in the odd half hours (or even occasionally whole hours) that I happen to find lying around, have fun producing a non-trivial working system that makes my life easier. This just wasn’t possible a few years ago - I remember ten years ago setting out to do some similar personal projects in Microsoft C++ version 1 (no Linux or Java then, and I hadn’t heard of perl or python), and there was just so much hard work and bullshit to wade through before you could actually get close to having anything useful, I gave up. The things I wanted to do weren’t worth sacrificing entire evenings and weekends to something that wasn’t fun. Now, with python running on a unix-powered iBook, it doesn’t have to take whole evenings and weekends and it is fun. Part of the fun is that the language is clean and elegant, part is the “wow, I thought that was going to be a big job, and now two hours later here it is working” factor.

It’s not just having a nice language to program in - it’s that plus free software and the web. Not sure how to do something? Google. Google doesn’t know? There’s always usenet. Standard library doesn’t do what you want? Download a better one. The language is a bonus, but I’m sure if I was a high-powered perl hacker I could churn out this stuff at about the same rate as I’m churning it out in python. The difference being, it would have taken me a lot more than a few weeks of part time dabbling to be as fluent in perl as I am in python. Java is probably fairly similar to python in terms of the ease of learning the actual language; its libraries are at least as good as the ones for python and perl, and better documented. But if I only have half an hour to get something useful done, I don’t want to waste half my time fighting with a brain-dead compiler that wants to to be told about every exception I might throw, forgets what my objects are every time I put them in a list, (etc. etc. etc. - refrains from launching into long rant about the amount of irritating time-wasting nonsense that is in java even though it’s basically a fairly nice language). So actually, on reflection, maybe having a nice language to program in is as important as those other things.

related entries: Programming

3rd October 2003 permanent link

I was a music download virgin until today. I installed a beta version of napster once but it didn't work; a little while ago I had a look at what was available from Apple, but I was unimpressed with the selection, and in any case I can't buy anything from them because I'm not in the USA. But then I noticed somebody on arstechnica recommending eMusic, and thought I'd have a look.

Not bad. Free trial downloads. No DRM. No big-name, big-label artists, but several indie-label artists that I'm interested in and didn't find on iTMS: Badmarsh, Blue Planet, Asian Dub Foundation …

And their classical offerings? Not all that impressive at first sight. Fairly small selection. But wait. They have the Janacek and Bartok string quartets, recorded by unknown East European quartets. Weren't the Kodaly Quartet an unknown East European quartet until they produced their superb Haydn recordings for Naxos? Maybe these guys are brilliant too. Certainly worth downloading them to find out. And they have four recordings of Beethoven piano sonatas by Alfred Brendel - those have to be worth a listen.

I think the selection is too limited for eMusic be a real competitor to iTMS if the latter ever actually appears outside the USA, assuming Apple get their indie label deals sorted out and actually have some of the stuff I want to hear. eMusic is cheaper if you can find more than ten interesting tracks a month in their catalog - which I suspect would be easy for the first few months but might get harder thereafter - but it feels more like an interesting bargain bin than a potential prime source of music.

Apple may have also much better sound quality than eMusic, if their codec is as much better than mp3 as some people seem to think.

The big unanswered question for me with eMusic is whether mp3s are actually good enough to have as your only copy of something worth listening to, or just a way of auditioning things that you're going to want to buy on CD (or iTMS) anyway if you find you like them. Which I'm not going to find out for a few days, because it's a holiday weekend in Germany and I seem to have left my headphones in the office. Oops. At some point I'll also download something from eMusic that I already have on CD so that i can do a direct sound quality comparison on my proper stereo (which, for those who care about such things, is a cheap-but-decent rig consisting of bottom of the range NAD amplifier and Kef speakers). I'll also be interested to see what stereophile magazine has to say about the iPod when their October issue comes online, particularly if they listened to AAC and mp3.

I thought I'd try a tabular comparison, but it probably overstates the advantages of eMusic:




availability worldwide US only eMusic
price $9.99 / month $0.99 / track eMusic if used heavily
selection very few big names, but some interesting indie stuff had hardly any of the things I looked for, but probably getting better fast eMusic, but probably not for long
Mac user interface ok very good iTMS
non-Mac availability Windows, Linux Windows coming some time, maybe eMusic, but not relevant to me
DRM none limited, reasonable eMusic
sound quality mp3 reputedly better than mp3 iTMS by reputation, but will reserve judgement until I've heard both
supported sound format widely used but inferior de facto standard superior but only supported by apple products depends how listenable I find mp3s
free trial 45 tracks no eMusic
minimum purchase 3 months @ 14.99/month 1 track @ $0.99 iTMS

related entries: Music Mac

the golden age of classical music

3rd October 2003 permanent link

The Golden Age of classical music was, for me, the late 1990s in Manchester. This might seem like a surprising statement, but read on.

There were three orchestras based in Manchester at that time. There was the Hallé - not what it once was, but still capable of producing the goods on occasion. There was the Manchester Camerata, an unknown but good chamber orchestra. And there was the BBC Philharmonic, the northern version of the BBC Symphony Orchestra - also not well known but not at all bad. Just down the road there was also the Royal Liverpool Philharmonic Orchestra, which was having something of a mini golden age of its own at the time. My brother had regular freelance gigs with the Camerata and the Liverpool Phil. My brother’s ex was in the Hallé and had been in the Liverpool Phil before that. My friend Rob’s friend Paddy was lead trumpet in the BBC Phil.

Manchester was also the base of the Lindsay Quartet, who spent the winter as musicians-in-residence at the university music department. They gave free concerts on Thursday afternoons in the university art gallery, which were basically rehearsals for their summer touring and recording season. As famous top-flight string quartets go the Lindsays are by no means my favourite, but it was certainly well worth taking the odd Thursday afternoon off work to see them for free.

I had never really taken a serious interest in classical music before, despite growing up in a household where non-musicians (me) were a minority. So it was all new and exciting. There was plenty of good music available. The contacts I had meant that I always knew what was likely to be worth hearing, and paying for concert tickets was mostly something that happened to other people.

Some high points of that era: going to hear the Hallé play Beethoven’s 7th symphony. Also on the programme was some guy I had never heard of called Kremer, playing a violin concerto by some guy I had vaguely heard of called Berg. It was stunning. (The Beethoven was fun too.) I went home and told my brother I’d just heard this guy called Kremer who was pretty good - my brother said “oh yeah, he’s probably the best fiddle player in the world at the moment”. Then there was the day I went to hear my brother in the Liverpool Phil playing Mahler. The composer Michael Tippett had died the day before. They wanted to play something to commemorate him but they didn’t have anything by him rehearsed, so they played Elgar’s Nimrod, which had apparently been one of his favourite pieces. It was stunning - a really good orchestra on a moving occasion producing the perfect performance. I never expect to hear anything like it again; if it had been recorded it would be on “recordings of the century” lists. I was wondering, afterwards, if the band actually knew what they had done - then my brother came into the bar and asked “did that sound as good as it felt?”. Oh yes it did.

Then I moved to Munich, which has a famous German Symphony Orchestra and a lot more performances by visiting Big Names. But I don’t know anybody in the music scene here, which means not only do I have to pay money to go to concerts, but when I do it’s more anonymous and less fun. So I don’t go half as much as I used to.

(This seemingly random reminiscence was prompted by a conversation with Brian Micklethwait about his current favourite violinist, Hilary Hahn, and the market for recorded classical music - irredeemably dire prospects thereof. Possibly more on that subject another time)

related entries: Music

the beauty of python

1st October 2003 permanent link

After only a few weeks of developing in python in my limited spare time, I'm discovering that it's remarkably easy to do things that look complicated and daunting at first sight. I've already mentioned the state of the art software engineering principles on which ayawt is based, two of which are:

  1. Do The Simplest Thing That Could Possibly Work
  2. For any given text-processing problem, XSLT is unlikely to be The Simplest Thing That  Could Possibly Work

Item (2) notwithstanding, it would be difficult to build a web page generator without some kind of templating mechanism. Fortunately, python comes with one built in in the form of string substitutions. In their simplest form they look like this:

'the %s is %s' % ('grass', 'green')

What this says is "replace the %s bits in the string with the values from the supplied list, in the order in which you find them", resulting in 'the grass is green'. Then there is a slightly more sophisticated version where the tokens to be replaced have names, and are looked up in a dictionary (hash table) of names and values.

'%(colour)s are the %(vegetable)ss' % 
	{'vegetable':'carrot', 'colour':'orange'}

... produces 'orange are the carrots'. This was what I decided was The Simplest Thing That Could Possibly Work for my templating mechanism.

The templates look something like this:

<!-- xhtml headers, link to stylesheet etc. ... -->

        <!-- etc etc ... -->

And I was fine as long as I made sure I had the same tokens in all my templates, (which I did by starting off with the same template for every page) but having to have the same tokens in all my templates clearly wasn't going to be a particularly flexible long term solution. What I needed for more flexibility was something that would parse all the token names out of the template, and dynamically build the dictionary of token values by mapping the names to properties of my page class. Not exactly a major problem conceptually, but in any language I've ever used before it would be rather more than I would expect to be able to knock out in half an hour on the train. Not in python, though, where turns out to be as easy as:

import re # standard python regular expression library

# regexp to extract tags from the template

rex = re.compile(r'%\((?P<value>.+?)\)') 

class page (object) :

     # ... initialisation code omitted
     def build (self) :
        tokenvalues = {} # empty dict
        for token in rex.findall(self.template) : 
            attr = self.__getattribute__(token)
            tokenvalues[token] = (callable(attr) and attr()) or attr        

        outfile = open(self.url, 'w')
        outfile.write(self.template % tokenvalues)  

Some metrics:

There are existing python templating libraries, webware psp and cheetah being two of the ones I've heard of. I'm pretty confident that it would have taken me more than 40 minutes to install, test and learn one of them and rewrite my templates. I'm absolutely certain it would take me more than 40 minutes to learn XSLT. And I think my approach is fairly flexible - in principle I could switch to a "standard" weblog templating language like blogger or Moveable Type just by changing my regular expression and adding a few methods (assuming I wanted not to be able to do all the cool better-than-blogger-or-Moveable-Type things that AYAWT will (?) be capable of one day).

Even for a novice python programmer like me, there are obvious ways to boil this down still further. Using python properties instead of attributes & methods would avoid the inelegant (callable(attr) and attr()) or attr bit without having to write heaps of ugly java-style get methods. Assuming python has a function for constructing dictionaries out of lists of value pairs (which I expect it probably does, and if it doesn't it would be a five minute job to write one) you could actually write the whole thing as a one-liner (note: pseudocode):

open(self.url, 'write').write(self.template % \
    dict([(tag, self.__getattribute__(tag)) \
    for tag in re.compile(r'%\((?P<value>.+?)\)'). \		

But would the one-liner actually be better, other than for deriving a smug sense of one's own cleverness bordering on that of Lisp programmers? Elegance and succinctness are in principle Good Things, and I don't have any problem with the legibility of the shorter version, but I can think of a number of practical arguments in favour of the slightly more verbose approach. Python's significant whitespace is generally nice once you get over the initial shock, but does get in the way of making elaborate one-liners legible - line continuation backslashes are ugly and a pain to type, and cause irritating syntax errors when you forget one. Complex nested expressions are harder to debug because you can't easily get at the intermediate stages. Compiling the regular expression in advance is probably slightly faster (minor benefit) and keeps the nasty regexp syntax as far away as possible from civilized code (major benefit). I don't know how in the one-liner to get and close the implicit file handle that we're writing to - it would be nice if python automagically closed it when it goes out of scope (and perhaps it does?).

But, leaving aside stylistic questions of slightly verbose versus as-terse-as-possible, python is really very nice.

related entries: Programming

all text and images © 2003–2008

< september 2003 november 2003 >