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.
I wrote a websnapr equivalent one time. I needed thumbnails of every website on the internet and favicons wouldn't do.<p>So my script:<p>1. connected to a database and found a list of sites it needed images of<p>2. checked the image table to make sure there was a recent (< 1 day) snapshot<p>3. if there was not, it would start X, take a screenshot<p>4. use photologue to compress it on-the-fly<p>5. save the picture<p>it was less than 200 lines, but it worked really well. that's still my pride and joy.
Here's a terrible brainfuck interpreter:
<a href="http://python.pastebin.com/f3d434dd2" rel="nofollow">http://python.pastebin.com/f3d434dd2</a><p>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!
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.<p>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.<p>All said and done I think it was a shade under a thousand lines and saved me weeks of exploration and hand coding.
I wrote a genetic programming system in python. <a href="http://paraschopra.com/sourcecode/GP/GP.zip" rel="nofollow">http://paraschopra.com/sourcecode/GP/GP.zip</a>
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.<p>90 lines of code.
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.<p>If you want to cut your teeth on some fun little challenges, you might try codegolf:
<a href="http://codegolf.com/competition/browse" rel="nofollow">http://codegolf.com/competition/browse</a>