Another Day, Another Dojo

My first Dojo of 2010 yesterday, as I missed the January one (which is a shame as it sounded like fun). This was a return to the conventional Dojo style with pair-programming at the front, the task being to merge the Adventure Game efforts from the previous month’s team-by-team effort. But first, a commercial break… Jonathan Hartley advertised the upcoming PyWeek competition and demonstrated his team’s previous effort as well as the amusingly literal Murder of Crows entry.

Meanwhile, back at the Dojo… Nicholas started off partly to set things up for people (like me, his co-pilot) who hadn’t been there the month before. As we moved through the programming pairs, we did manage to get a working codeset together by merging the location-parsing code from one team with the cmd-based loop from another. But it was clear that things were moving slowly and that the audience was somewhat disengaged…

So we finished off with a broad discussion of ways ahead, of what might work better, and of whether the artificial nature of the Dojo setting meant that people couldn’t “show off”, so to speak, their natural coding style — and ability. Michael G and others made a few cogent suggestions to the effect that smaller teams would work better but with some kind of DVCS (git seemed to be the front-runner) to assist the teams in collaborating. And it seemed that at least one team should be creatives, rather than coders.

I enjoyed it, as ever, but it _is_ difficult to keep 20+ people in a medium-sized room totally engaged. Even with the best will in the world, it’s hard to read code on a screen from some distance back. This was one of the reasons why a team-based approach met with broad approval. Also it is a little dispiriting when you’re doing your best up front but half your “audience” is otherwise engaged.

The point about how “natural” you should be in the Dojo was interesting. Everyone has a different way of coding, of approaching a problem, of looking for information and so on. Dave[*], the last pilot, mentioned that he’d normally take much longer sizing a problem up but that having a time limit forced him into action sooner. But you’re up there with a limit of 10 minutes, probably on someone else’s machine, maybe on an “alien” operating system. You’re fumbling with running up a command prompt; you’re not sure how to bring up the Python docs; the keyboard shortcuts which your fingers remember don’t work — or worse, do something else entirely! We did discuss each person bringing up his own laptop, although that has obvious drawbacks of getting the projector to switch smoothly and so on. It was out of this discussion that the move towards a team-based approach next time arose.

TJG

[*] Dave, incidentally, was the programmer of the BBC version of the Graphics Adventure Creator — did you know that?

Usefulness of itertools.cycle & re.sub

(… or at least the concept). I wanted to process a piece of plain text which would include conventional double-quote marks in such a way that they became HTML smart quote characters (&ldquot; &rdquot;). I was prepared to adopt a naive algorithm which assumed that alternate quotes would always match up, something which obviously wouldn’t work for single quotes. I toyed with various ways of splitting the text up and joining it back together until I came across the slick combination of itertools.cycle and re.sub:

import itertools
import re

quotes = itertools.cycle (['&ldquot;', '&rdquot;'])
def sub (match):
  return quotes.next ()

text = 'The "quick" brown "fox" jumps over the "lazy" dog.'
print re.sub ('"', sub, text)

Obviously my itertools.cycle could trivially be written as: while 1: yield '..'; yield '...', but why reinvent the wheel?

Update: Tom Lynn points out that this can be done with a straightforward regex:

text = re.sub(r’”([^”]*)”‘, r’&ldquot;\1&rdquot;’, text)

Poppy Day again…

It was quite a while before I realised that using Poppies to commemorate Remembrance Sunday (and the fallen of wars in general) wasn’t universal. I don’t know if it’s practised anywhere outside the UK, in fact. But here it’s pretty much the only one of the many collections-for-good-causes which has widespread appeal, partly because it’s a tradition which long precedes pretty much every other save-the-something collection. Partly, I think, because we’re all human and who can argue with collecting money for such a cause?

As it happens I haven’t seen many poppy-sellers around where I work in Camden Town. But I knew that today — Saturday before Remembrance Sunday — the local cadets would be out in force (and in fatigues) around Ealing where I live, armed with Poppies and collecting tins. And they didn’t disappoint. I am, for several reasons, not a great fan of cadets and school OTC outfits. But, at least where I live, this is pretty much the only example of seeing groups of young people on the street doing something for the good of others. The Scout movement has reinvented itself as a training scheme, as far as I can see; and in any case, it’s been years since anyone would have been seen dead on the street in a Scout uniform.

So I bought my poppy from a young man in army outfit who looked a little lonely at the side of the main Shopping Centre square. And I hope you’ll all do the same.

London Python Dojo: that was interesting…

Thursday night saw the third London Python Dojo, which involved us completing a — very simple — noughts & crosses game, with a random computer player which seemed have a winning streak a lot of the time!

Why interesting? Because, for whatever combination of reasons, there were fewer people there: about 10 of us, compared to something around 25 the last couple of times. One obvious factor was that it was November the 5th, so many people would have been with their families at fireworks displays. It might be that the attraction had palled, but I doubt if that accounts for everyone. However it came about, we had a reduced number.

That meant two things, I think: that everyone had a go at piloting (or at least co-piloting; I don’t thing Peter actually coded at all); and that everyone was engaged to a greater extent, just because there were fewer people. (Possibly also because those who did come were slightly keener…). I had a great time, and the audience participation, which was certainly there as I made a mull of trying to get clever with an itertools.cycle, was more — how shall I put it? — manageable. It also meant that there were fewer people still at the pub, and we had a quiet corner to ourselves, which I find more pleasant than shouting at someone in an awkward corner of a noisy and crowded room. (But then, I’m not really a pub person).

Apart from small bits and pieces, most of the time around the pub table was spent debating a proposal of Jon’s that Security bugs are always logically more important than any other class of bugs, because whatever effect another bug can be caused can just as well be caused by someone breaking into your system, making that happen, and then doing whatever they were going to do anyway (sending your credit card details to the Russian mafia, etc…).

As Nicholas has already posted, we discussed various ideas around the future of this particular meetup. We definitely all agreed that it should *have* a future, and more or less coalesced around the idea of a regular, but varying, lineup which might include Dojos of different types, but would also have more conventional talks / lightning talks etc. The idea also would be to keep it in the first week of the month, thus alternating with the Pyssup which is in the third week, but varying there’s always some day *someone* can never make. (For me, it’s Wednesday). It was also agreed that “official” communications would happen on the Python-UK list as everyone can easily see that; not everyone has Twitter / Wave / the-latest-and-greatest-thing.

Personally, I think Fry-IT are very generous in not only allowing us to use their offices, but also providing beer & pizzas. It makes it much easier to talk to people before, after (and even during). If you’re in or around London in the first week of December, why not turn up? Watch the python-uk mailing list for info.

Bottom-posting considered confusing?

Not a specifically Python-related post, although most of my mailing list activity is Python-related. Anyone who’s spent a more than negligible amount of time following any of the Python lists will have encountered the “We Bottom-Post Here” reaction to posters who top-post. Personally it makes sense to me, altho’ I do sometimes feel that people are too forthright about things of this sort.

That said, my experience among practically all my colleagues, friends and relations is that bottom-posting or inter-posting (ie snipping segments of an email and replying to them immediately afterwards) is downright confusing. You can blame the phenomenon on the default behaviour of certainly commonly-used email clients if you like. But I’ve had several people reply to me in puzzled tones along the lines of “Why do you put your comments under my comments like that?” or even “I think you pressed the Send key too soon…” when I’d replied at the bottom of their email rather than at the top where they expected it.

Ultimately, When in Rome… I think bottom/interposting makes more sense, but if it makes less sense to my correspondents then I view that as my problem and not theirs.