Eureka moments in Python

Alex Martelli aleax at mac.com
Thu Mar 15 23:39:17 EDT 2007


Steven D'Aprano <steve at REMOVEME.cybersource.com.au> wrote:

> I'd be interested in hearing people's stories of Eureka moments in Python,
> moments where you suddenly realise that some task which seemed like it
> would be hard work was easy with Python.

As a part of my process to decide whether Python was the right language
for me to use, right after reading the 1st edition of "Learning Python"
hot off the presses, I decided to invest a weekend getting a start on a
specific task -- a web app (CGI) to compute conditional probabilities of
suit divisions (for many possible conditions) in contract bridge.
Hard-coded English output was to be the "first iteration" -- then in a
second iteration, besides adding fancy conditions, I'd develop some
templating system and pick the language to use from the browser to
switch to an appropriate directory of templates for the user's language.

I didn't really think I'd finish the first iteration in the weekend, but
the conditions were favorable: wife and kids were out of town and the
larder well stocked with coffee, prosciutto, parmigiano, and bread.  So,
I could hack for a few hours before falling asleep on Friday night, and
about 16 hours each on Sat and Sun -- a total of 36 hours or such should
let me at least put some serious dent on the problem, if this language
did prove to be the right one for me.

I got home around 8pm), made myself prosciutto sandwiches, and got
going.

At about 4pm on Saturday (despite having gotten a normal night's sleep
in the meantime), I looked at what I had so far... the system as
originally envisioned, completed, with all kinds of conditions coded,
and working just fine, the general-purpose templating system all done
too as well as English, Italian and French templates to try it out, a
nice battery of unit-tests and integration-tests, and lots of
optimizations (such as, memoization for the factorial function) already
integrated too.

I had to face the facts: I had achieved in about 12 hours (including
time to brew myself coffee, prep sandwiches, and stroll to the bar for
an espresso to wake me up in the morning) over twice as much as I
thought, somewhat optimistically, I could have gotten done in 36.  And
that, in a language completely new to me, with nobody else around to
help me out (at that time, I didn't have an always-on net connection,
and I hadn't dialed in during those hours either).  [[the application
domain _was_ familiar to me, but I had factored that in as part of my
estimate of how long the whole task would take]].


_That_ was the "Eureka moment" that sold me on this newfangled
language...!


Alex



More information about the Python-list mailing list