Today I Learned

Patrick Rhone has this thing where he learns something new every day. I like the idea so I've decided to steal it and write what I discover in my logbook1. The question, of course, is where to find something new every day. Patrick lists some ideas and they're all good.

It occurs to me that both the Wikipedia page for the day and the Today I Learned subreddit could also be useful sources of fact nuggets. And since I haven't posted any code here for a while, I thought I'd write up a quick little Pythonista script to aid in this quest for knowledge.

from datetime import date 
import webbrowser 
import console

def main(): 
    result = console.alert("Today I Learned", "Choose your path", "reddit", "today", "random") 
    today = date.today().strftime("%B_%d")

    urls = ["http://www.reddit.com/r/todayilearned", ("http://en.wikipedia.org/wiki/%s" % today), "http://en.wikipedia.org/wiki/Special:Random"]

    url = urls[result-1] 
    webbrowser.open(url)

if __name__ == '__main__': 
    main()

I believe that Pythonista's console.alert method limits you to three choices, so I've populated it with the three options that I find most useful. It's easy enough to change the values in the url variable if you like something different. With clever use of URL schemes you could even have the pages open elsewhere, like Wikipanion. If you use Launch Center Pro you could even set it up to autolaunch the script at a certain time every day. But you already knew that.

And here's the gistification as well for easy importing to Pythonista.

https://itunes.apple.com/us/app/launch-center-pro/id532016360?mt=8


  1. Another idea I stole. 

Share on App.net

Comments !

++useful

elsewhere