Python limericks

Thursday 24 March 2005This is more than 18 years old. Be careful.

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:




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.
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...)
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:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.