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))Michael
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:
DA-DA-DUM DA-DA-DUM DA-DA-DUM
DA-DA-DUM DA-DA-DUM DA-DA-DUM
DA-DA-DUM DA-DA-DUM
DA-DA-DUM DA-DA-DUM
DA-DA-DUM DA-DA-DUM DA-DA-DUM
Genius!
Comments
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: