

Ask HN: the most amazing python script you ever wrote ? - ideamonk

As I learn python, i wonder what was the most funny/amazing python script you wrote during your work/education ? and how it helped.
Maybe I could also do them as an exercise to build up some python skills as i experiment more and more to learn it.
======
omarish
I wrote a websnapr equivalent one time. I needed thumbnails of every website
on the internet and favicons wouldn't do.

So my script:

1\. connected to a database and found a list of sites it needed images of

2\. checked the image table to make sure there was a recent (< 1 day) snapshot

3\. if there was not, it would start X, take a screenshot

4\. use photologue to compress it on-the-fly

5\. save the picture

it was less than 200 lines, but it worked really well. that's still my pride
and joy.

~~~
ideamonk
wow that sounds great :)

------
pshc
Here's a terrible brainfuck interpreter:
<http://python.pastebin.com/f3d434dd2>

I wrote it as an exercise in functional style, and so it has no mutation
(other than the tuple assignment in the main loop, which I couldn't devise a
functional equivalent for). It is incredibly inefficient as a result. But it
all fits in a single Python statement, save initialization!

------
icey
A few months ago I wrote a python script that built relation data from a
database using only primary key data (all the PKs were GUIDs) to build a
mapping of the actual relations from the database. This particular application
had grown quite large and no relationships were ever really documented.

Then once the relationships were all mapped out, I wrote another Python script
to shell out C# classes for all of the tables and their relations so that I
had an easy way (data library + basic web forms) to explore the data.

All said and done I think it was a shade under a thousand lines and saved me
weeks of exploration and hand coding.

------
paraschopra
I wrote a genetic programming system in python.
<http://paraschopra.com/sourcecode/GP/GP.zip>

------
gaius
I don't know about the most amazing, but I am constantly impressed by how much
work you can get done in so little Python. Last script I wrote 1) parses its
command line 2) tries a list of servers to find the logfile it needs 3)
retrieves and parses that logfile 4) fits a trigonometric polynomial using
Fourier series 5) draws the original data plus the curve fit on a graph and
saves that on a web server.

90 lines of code.

------
thorax
I've written a lot, but none I'd characterize as funny or amazing. I've
enjoyed most writing the wrapper classes for embedding Python in Counter-
Strike: Source, but there's nothing amazing there.

If you want to cut your teeth on some fun little challenges, you might try
codegolf: <http://codegolf.com/competition/browse>

~~~
ideamonk
yepp! how could i forget codegolf :)

------
habnabit
<http://paste.pocoo.org/show/91848/>

