I used to play sports. Then I realized you can buy trophies. Now I’m good at everything.
Posted by Mike on Feb 19th, 2009
I stumbled across “Dammit I’m Mad” by Demetri Martin, a rumored-to-be 224 word palindrome poem.
I was impressed, but needed to check the accuracy of such a statement. So I dialed up a python session.
import re awesomedrome = """Dammit I'm mad. Evil is a deed as I live. God, am I reviled? I rise, my bed on a sun, I melt. To be not one man emanating is sad. I piss. Alas, it is so late. Who stops to help? Man, it is hot. I'm in it. I tell. I am not a devil. I level "Mad Dog". Ah, say burning is, as a deified gulp, In my halo of a mired rum tin. I erase many men. Oh, to be man, a sin. Is evil in a clam? In a trap? No. It is open. On it I was stuck. Rats peed on hope. Elsewhere dips a web. Be still if I fill its ebb. Ew, a spider... eh? We sleep. Oh no! Deep, stark cuts saw it in one position. Part animal, can I live? Sin is a name. Both, one... my names are in it. Murder? I'm a fool. A hymn I plug, deified as a sign in ruby ash, A Goddam level I lived at. On mail let it in. I'm it. Oh, sit in ample hot spots. Oh wet! A loss it is alas (sip). I'd assign it a name. Name not one bottle minus an ode by me: "Sir, I deliver. I'm a dog" Evil is a deed as I live. Dammit I'm mad.""" # strip out all punctuation just_the_chars = re.compile('\W').sub('', awesomedrome).lower() def test_palindrome(): # chars[::-1] gives the reverse of the resulting string assert just_the_chars == just_the_chars[::-1]
I stripped out any non-word characters (punctuation, space, etc) with the regular expression, lower-cased it all, and compared it front to back.
$ python is_demtri_a_god.py not exactly
As you can see, it’s not palindromic.
So close.
$ nosetests test_demetri.py . ---------------------------------------------------------------------- Ran 1 test in 0.001s OK
Update 4/22:
Not sure why the original script used to doubted the claim to palindromity, but I’ve fixed it now. Demetri really does rock our socks off!
- Filed under off topic, software development
- Tagged with humor, python
- Comments(2)

April 22nd, 2010 at 1:31 am
I just ran your python script, and it told me that the string is in fact a palindrome. Something must have gone wrong when you ran it. The problem might be related to the unicode ellipses on lines 16 and 20. It might work better if you used ASCII only.
Anyway, you should double-check your results.
April 22nd, 2010 at 9:35 am
Thanks for the heads up Monty! Updated post…