Sometimes, I need to find a ratio approximation of a number. Like 640 / 480 (vga) or similar number. I learn about farey series a few years ago (1994). The <a href=http://en.wikipedia.org/wiki/Farey_sequence>idea</a> is actually quite simple.
>>> farey(math.pi,100) (22, 7)
Get the implementation <a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317>here</a>.