Python limericks

Thursday 24 March 2005

A thread on comp.lang.python asking about text-to-speech libraries turned into a call for Python limericks. The discussion meandered on for a while (let's just say there's a reason most of these people are engineers rather than poets), until Michael Spencer posted this piece of brilliance:

How about a category for executable limericks?

Here's one to get the ball rolling:

# voice only the alphanumeric tokens

from itertools import repeat
for feet in [3,3,2,2,3]:
     print " ".join("DA-DA-DUM"
     for dummy in [None]
for foot in repeat("metric", feet))


P.S. I know 'three' doesn't rhyme.

Not only is the Python code itself in the form of a limerick, but if you run it, it prints this:




andrew 10:08 PM on 24 Mar 2005

You have just gone off the geek scale into dorkage lands none have ever seen. I would salute you if I didn't want to give you a wedgie so bad.

Ned Batchelder 5:35 AM on 25 Mar 2005

Hey, I categorized it under "geeky"! (of course, some would say that having a category called "geeky" just cements one's reputation as a geek...)

Andre 8:34 AM on 4 Apr 2005

py2.3-compatible version: replace generator display with list comp.

from itertools import repeat
for feet in [3,3,2,2,3]:
    print " ".join(["DA-DA-DUM"
    for dummy in [None]
for foot in repeat("metric", feet)])

Add a comment:

Ignore this:
not displayed and no spam.
Leave this empty:
not searched.
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.