TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

6 pointsby ideamonkover 16 years ago
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.

7 comments

omarishover 16 years ago
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 (&#60; 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.
评论 #374467 未加载
pshcover 16 years ago
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!
iceyover 16 years ago
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.
paraschopraover 16 years ago
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>
gaiusover 16 years ago
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.
thoraxover 16 years ago
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>
评论 #374469 未加载
habnabitover 16 years ago
<a href="http://paste.pocoo.org/show/91848/" rel="nofollow">http://paste.pocoo.org/show/91848/</a>