Sunday, January 16, 2011

One space or two

It's a little depressing but also undeniable that I am getting to be an old fart. My birthyear satisfies this equation:


2010 - b == b % 100


For today what it means is that I learned to type on a typewriter, an archaic device you can read about in wikipedia (here). My first two were unpowered. In typing class, my teacher was very strict: it was an error if you did not have two spaces separating sentences. In typography, or even when typing on a computer, the rules have changed, but legions of us still type to please the critical eye of someone like Brother McDermott.

Apparently that drives certain people crazy (here) or just leaves them bemused (here and here).

I still do it, as you can see it in the source for the blog. It's arguably correct for non-proportional fonts. But, in the end it doesn't matter because html simply ignores the extra space.

What does matter and I find incredibly useful is to separate groups of multi-line data by a double newline. Then I can just do:


L = data.strip().split('\n\n')


It's mildly irritating when I send off a FASTA file in that format and it comes back without the extra newline. Then I have to split on '>', throw the first item in the list away, and add back the '>'. Arggh.

Another useful Python idiom is:


title, seq = item.strip().split('\n',1)


I always strip, just to be safe.

No comments: