{"id":140,"date":"2006-06-02T13:19:46","date_gmt":"2006-06-02T20:19:46","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/140\/learn-python"},"modified":"2016-08-08T09:13:57","modified_gmt":"2016-08-08T13:13:57","slug":"learn-python","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/140\/learn-python","title":{"rendered":"Learn Python"},"content":{"rendered":"<p>I have never gotten very good at any of the popular shell scripting languages. Over the years, I&#8217;ve dabbled in Bourne sh scripts, Perl, awk, and sed. I was never one of those magical guys who could make anything happen in a few seconds. But I&#8217;ve always wanted that to change.<\/p>\n<p>\nI&#8217;ve decided to learn Python. I want a fast-acting Swiss Army Knife at my disposal for splicing together the loose ends of my computer life.\n<\/p>\n<p>\nWhy Python? I don&#8217;t know it well enough to really sing its praises, but a number of influences caused me to veer towards this language (as opposed to say, improving my Perl or picking up Ruby):\n<\/p>\n<ol>\n<li><strong>A Killer App<\/strong>. <a href=\"http:\/\/nodebox.net\/\">NodeBox<\/a> was the catalyst for this whole pursuit, though it has nothing to do with productivity, per se. I downloaded NodeBox on the recommendation of a friend, and was instantly blown away that such a tool exists at all. NodeBox makes it easy to programatically produce graphics on the Mac, exploiting the Quartz graphics capabilities of the system. Python happens to be the language for driving these amazing dynamic documents.<\/li>\n<li><strong>A Good Reputation<\/strong>. I started dropping Python references among groups of programmer nerds who I respect. Almost universally people either didn&#8217;t respond (people like me), or else raved about how great it was. About the only thing I ever hear people complain about with Python is its strict indentation rules. Hey. I&#8217;m a C programmer, but I have style. Indentation is <em>OK by me<\/em>.<\/li>\n<li><strong>Support From &#8220;The Man&#8221;<\/strong>. I&#8217;ll admit it, I am more likely to embrace something if Apple does it first. It&#8217;s just easier to get involved and stay involved with a technology when you know that there will be value-added by the most influential company in your little neck of the tech woods. Apple has included Python with Mac OS X as a standard part of the system, and even gone so far as to provide special Python bindings in frameworks like Quartz to facilitate the above-mentioned scripting tricks. I can embrace this language without worrying that its functionality on the Mac will suddenly disappear.<\/li>\n<li><strong>A Decent Tutorial<\/strong>. The biggest roadblock to learning for me is finding the start of a good path. If there is an incremental process I can follow to get better at something and eventually &#8220;know it,&#8221; then it&#8217;s much easier to tackle. The author of Python himself, <a href=\"http:\/\/www.python.org\/~guido\/\">Guido van Rossum<\/a>, provides a short-and-sweet <a href=\"https:\/\/docs.python.org\/2.5\/tut\/tut.html\">tutorial<\/a> that made it easy for me to get to know Python.<\/li>\n<\/ol>\n<p>\nI have a little trick with these &#8220;short chapters&#8221; tutorials. I keep a bookmark to the &#8220;next chapter&#8221; in my Safari bookmarks bar, and add reading it to my ToDo list for the following day. When I finish the chapter, I update the toolbar bookmark and wait until the next day. That way the learning is never overwhelming &#8211; just a few minutes aday, and it still only takes me a couple weeks to get through the whole tutorial.\n<\/p>\n<p>\nThis trick is OK, but while I was taking this tutorial, I got annoyed by having to constantly flash back and forth between the web page and my Terminal window. The Python tutorial introduces you to ideas that, if you&#8217;re anything like me, you immediately want to try out in the interactive shell. I decided to take a cue from Michael McCracken, who recently produced and distributed a dumbed down web browser just for <a href=\"http:\/\/michael-mccracken.net\/wp\/?p=44\">reading Gmail<\/a>.\n<\/p>\n<p>\n<a href=\"http:\/\/www.red-sweater.com\/blog\/downloads\/LearnPython1.0.zip\">Learn Python<\/a> is a simple Mac OS X application (GNU License, source included) that puts a web browser and terminal window into one application. The web browser points at the aforementioned Python tutorial on the web, and it remembers the last URL you went to, so you can trust it to remember which chapter you were at when you last quit.\n<\/p>\n<p>\nIt&#8217;s a Python-Tutorial Browsing Machine!\n<\/p>\n<p>\nBy almost every possible measurement, this project was a &#8220;waste of time.&#8221; But sometimes you&#8217;ve got to make the software you wish existed, just so you know it does. I rationalize the time as well-spent since it sets me up to easily crank out one-offs of a similar vein as I find a use for them. If I was really bored I would probably have added &#8220;value added&#8221; buttons to the UI for specifically navigating the document structure (e.g. next chapter, etc). But I think I&#8217;m done for now. Hopefully most of the bugs are ironed out.\n<\/p>\n<p>\nI hope some of you will get some use out of this extremely narrow piece of work. At least it might encourage you to learn Python!\n<\/p>\n<p>\n<strong>PS:<\/strong> Unhappy with the default version of Python that gets launched? Or wish you could use the tool as a ruby or shell scripting or whatever tool? I haven&#8217;t put any preferences in this application, but it would be easy enough to hack the sources. If you aren&#8217;t feeling up to hacking the sources, or don&#8217;t have the tools handy, you can specifically override the path of the launched tool by editing the file &#8220;Localizable.strings&#8221; in &#8220;Learn Python.app\/Contents\/Resources\/English.lproj\/&#8221;. Inside this file, change the line:<\/p>\n<pre>\r\n\"\/usr\/bin\/python\" = \"\/usr\/bin\/python\";\r\n<\/pre>\n<p>That will tell the application to use zsh instead of python. Replace the &#8220;\/bin\/zsh&#8221; with whatever you want.\n<\/p>\n<p>\n<strong>Update<\/strong> (June 3, 2006): The download has been updated to version <a href=\"http:\/\/www.red-sweater.com\/blog\/downloads\/LearnPython1.0.zip\">1.0.3<\/a>, which now defaults to a left-right orientation for the web and python shell panes. The setting can be changed back to top-bottom through the preferences dialog.<\/p>\n<p><strong>Update<\/strong> (June 4, 2006): Rodney Ramdas posted a modified version of the application that is targeted at <a href=\"http:\/\/www.pinupgeek.com\/articles\/2006\/06\/04\/learn-ruby-app\">learning Ruby<\/a>, instead. I&#8217;ll probably use it to tackle Ruby, next!  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have never gotten very good at any of the popular shell scripting languages. Over the years, I&#8217;ve dabbled in Bourne sh scripts, Perl, awk, and sed. I was never one of those magical guys who could make anything happen in a few seconds. But I&#8217;ve always wanted that to change. I&#8217;ve decided to learn [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,12,4],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-hacking","category-usability","category-web"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":1,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":3172,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions\/3172"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}