Learn Core Python in a Week – My Way

By , July 16, 2011

@curphey on Twitter and on Google Plus

I took a week off of work this week to learn Python. Truth is I have been trying to learn Ruby (and) or Python on and off for the last 18 months or so but work and kids (and the “dog ate my homework” syndrome) have always found priority and I made little meaningful progress. After a big release at work I checked my vacation balance, bit the bullet and booked this week off work. I told everyone I was going dark. It’s Friday and so far I am feeling like I have really got to grips with the basics of the core of the language. I am now in a place where I can be productive writing code and solving my own problems. I think I now have the basic level of knowledge to continue learning and overtime actually become a half-decent decent Python developer. In this post I share how I approached getting my results so far.

If you want to know why I wanted to learn a language and why I want to learn Python in particular there is of course a short story. I got involved in computer security via formal education (cryptography and mathematics). As my career progressed through start-ups and financial services companies I became good at managing technical projects and managing technical teams. Through personal interest I steered towards running software security programs and running teams of developers building software security tools. For the last five years I have been more interested in “software” than “software security” and while I am no pointy-haired boss (I have picked up a lot along the way) I have never been formally trained as a computer scientist or worked as a commercial software developer (code contributing developer). When I turned forty, two years ago I had the classic mid-life crisis. I took up distance running and evaluated my long term career plans. Many people start off their careers as highly technical individual contributors and slowly morph into spreadsheet crunching people managers. Power, money and (pseudo) respect in most corporate structures is understandably aspirational for some people but having been there and done it, I made a conscious decision to morph my career back the other way. I won’t ever stop wanting to lead teams of smart motivated and passionate people but I want to be a grass roots technical contributor creating meaningful software. I could write a very long post indeed on how I think the very nature of software teams is changing way beyond Agile and how I think the future is very small self-contained teams operating in an eco-system but perhaps for another day. The short summary is that I decided I wanted to be the member of a rock band and not a member of an orchestra and want to lead software teams from within.

Why Python? With the huge choice of languages and having explored a number over the years (Java, Ruby, Perl, C#) I decided to pick one with a view to becoming proficient in it rather than try and become a “jack of all trades” in a few. I view JavaScript and CSS as base knowledge for any modern developer so didn’t include those in the scope of my decision. You have to know them regardless if you want to build web applications. I have always been passionate about open source software and so one pre-requisite that there was a strong open source community (online, local meetings etc.) and eco-system (tools, components etc.) behind my language choice. At college in ’97 I first played with Java back when it was all about applets, then later when I ran the software security program at Charles Schwab between 2001 and 2003 we were all about EJB so Java might have been a natural choice and the eco-system is clearly very strong, but for some reason the community around Java doesn’t excite me. For me it essentially boiled down to Ruby vs. Python and to cut a long story short Python won. While Ruby has stronger test support with Cucumber (and friends) and of course a first class web framework in Rails, the developer community felt arrogant. Hang out on a ruby language mailing list for a week and you will know what I mean! Python on the other hand has a very strong scientific community behind it with a wider range of libraries for a broad spectrum of science things like bio-informatics. There is a great MVC framework called Django and in recent years Google has adopted it as one of its formal language for both use internally and on the Google App Engine. There is no real science behind my choice and it is very much personal preference but simply put it feels like a decent choice at this time.

Of course there will be a lot of code, a lot of learning and a lot of time before I will be a competent developer, if you are like me and want to learn Python (and have a day job that seems to get in the way) here is what has worked for me that you may want to consider.

1. Book a dedicated week – This is by far and away my number one tip. I took last Friday off to deal with the inevitable bow-wave of mail from work so I could enter this week 100% clear of any work issues. I structured my day with a 5 – 6 mile run every morning (obviously optional) followed by 4 hours of dedicated coding time. I take a break for the afternoon and then follow-up in the evening for a few hours (no fixed length) to cover any loose ends, extra reading and preparing for tomorrow. I created a bow-wave of learning so I wasn’t going into this week cold by starting tutorials a few weeks ago. This allowed me to focus this week on exploring important concepts and not understanding basic theory. I knew what I needed to learn going into this week and what success looked like for me so created my plan for the week (see below) ahead of time.

2. Agile Planning – I scoped out my work using Agile planning techniques. This maybe overkill but got me into the right mind-set. I used the community edition of Rally and set up a backlog and daily iterations. I even entered exercises as tests to prove my knowledge to myself. I have been able to look at my backlog, add stories and tasks and get better at estimating my velocity as the week wen’t along. Other decent free options for this include Pivotal Tracker or Agile Zen.

3. There is no substitute for writing code – You can read as many book as you want and write code in your mind but there is no substitute for writing code on your computer. It really is the only way you will learn syntax, semantics and how things really work. Don’t fool yourself into reading a chapter of a book or watching a video, writing code is what teaches you to write code. There is nothing more to say on that topic. Zed Shaw’s “Learn Python the Hard Way” echoes this. Use the Python shell as much as you can to experiment. iPython gives you a great extended shell to play with.

4. Hire (pay) a good instructor – Having a good mentor / instructor is essential. I was lucky enough to have a very smart friend (who is very, very good developer) last year agree to meet me for coffee every other week and teach me some Ruby. I never really made progress. Reason? I wasn’t committed. I never had to pay him, I would meet and catch up on a social level and our relationship was based on friendship and not on learning. This time I did some Googling, found out that the local University (University of Washington) ran an extension class and emailed the lecturer asking for private lessons. I met him for coffee first to make sure there would be a social fit and that his style would match what I was looking for. It’s not cheap (although all up will probably be 50% of the cost of doing a formal class like this) and has allowed me to operate at my own pace and on topics I want to cover. We can get side-tracked when we want. The lecturer (Brian Dorsey) is great and I look forward to meeting. During this seven day sprint we planned to meet three times and every Friday for a few weeks before and afterwards.

5. Use the Right Learning Material – Over the years I have bought a lot of language books. They range from step-by-step instructional books like the APress or Head First series to less structured books like the O’Reilly language series. While I have gotten a lot from them I have either found them to be “draw by numbers” or not organized in the way I wanted to learn. Bryan suggested “Python for Software Design – How to Think Like a Computer Scientist” which is what the UW course is based on. You can get a free PDF version here. The book has been a perfect fit for me as it talks about computer science in terms of recursion and stack diagrams and has exercises to build fractals and solve math problems. It is an an academic level that I can relate. The right material has really had a significant impact on my learning this week.

6. Use an IDE – Many purists will expose that using a text editor like TextMate (which I own) or TextWrangler is the best way to learn but for me using a fully fledged IDE has been a serious benefit. I use PyCharm and for the most part love it. When you are exploring an API you can see the functions it supports and syntax errors are highlighted as you type. While this could indeed make you lazy I think it helps you get up to speed faster so that the syntax becomes second nature. For me it’s like the difference between using a text editor or word processor to write a story.

7. Use good development practices as you learn – All week I have put my code into revision control. I generally use Git so also took the opportunity to learn Subversion this week (my only real violation of my next tip but it was so simple that …). I comment all my code no matter how trivial the example and even took to running it through the Python style guide PEP-8. Towards the end of the week I have even taken to writing unit tests for all code. Python Koans are great for learning testing in Python.

8. Just Learn the Language, Nothing Else – It’s very tempting to also learn Django at the same time as learning Python. If you want to build web apps you will need a framework to build on but I think it has been very valuable to separate the two. Apart from separating the complexity and scope it forces you to focus on the language only and not how to use the language to drive a framework.

That’s it for now. If I can think of more I will add it and I would love to hear others tips and tricks.

Useful References

A Jump Start for Learning Python

33 projects that make developing django apps awesome

http://learnpythonthehardway.org/

ipython

Python Koans

 

 

 

 

Share on TwitterSubmit to reddit
  • Dipankur

    What is your take on Scala

  • http://www.breakthesecurity.com Blackstar

    pythons are still worth to learn?

  • http://www.roxberry.pro Mark Roxberry

    Hey Mark, great write up – I did the same kind of thing with Ruby and Rails, except for hiring an instructor. I called it Agile Learning – and my main principle was to approach it as a professional. Timelines, sprints, daily scrums, version control, comments – all the stuff you mentioned. However, allow for some exploration and creativity. I created a “capability framework” to create an app and learn feature by feature (both horizontal, e.g. view helpers and vertical, scaffolding). I created a prototypes branch and when I was happy with my work, merged into the main trunk.

    I don’t want to get you ahead of yourself, but the next phase for me is teaching a QA group how to code in Ruby and Rails (with a primer for html / css / javascript). I’m finding that teaching it is a real kick in the ass – especially to folks who are clean slates.

    Thanks for the generous write up of your approach, it was enlightening.

  • Nitish

    Ruby with an arrogant community??? I would STRONGLY disagree.

  • http://pytools.codeplex.com sean

    On the IDE front, if you are visual studio user, the new microsoft plug-in for VS is worth checking out. it support both CPython & IronPython: edit/intellisense/debug/profile/etc.

  • Mike

    What’s missing for me is tips on what problems to solve to learn to code. I regularly use books with simple examples, but I could use some better real-world examples/challenges to solve using a new language.

  • http://epeus.blogspot.com Kevin Marks

    DId you look at http://diveintopython.org too?

  • Sebastian

    Hi Mark, nice writeup.

    I also do not endorse the idea of only using a text editor. however a full fledged ide can be overwhelming to the beginner. i personally also use PyCharm (been an Idea user before and love it), but for beginners i would suggest something like Wing IDE 101, a learner’s edition of the Wing IDE. it has syntax higlighting and a debugger, which is really helpfull, autocompletion is disabled, so that the pupil has to actually remember things, which, in the beginning is more helpful than not. later he can upgrade to whatever ide he likes best.

    also: i’m getting old: “javascript as base knowledge for any modern developer”? but that’s just taste i supppose. and i don’t like work in this area.

  • http://accidentalhacker.com Rob Sobers

    Nice post, Mark!

    I’m doing something very similar right now. I was also choosing between Python and Ruby. I elected to go with Ruby. I talk about it here:

    http://www.accidentalhacker.com/becoming-a-ruby-on-rails-developer-day-1/

    “Just learn the language, nothing else.” This is great advice. I tried to learn Rails and Ruby at same time and I found it distracting.

  • Scott

    Nice article. I’d be interested in reading about your views on sticking with development as opposed to going in the ‘normal’ progression of manager. I’m quickly approaching 40 and have been developing and designing web applications for about 10 years now. I have no genuine desire to be a manager, though of course am at the same time thinking it’d be wise to leverage my skill over something greater than providing a simple service. Truth be told I endevelopingjoy and would rather leave the management and marketing to others once it gets to a certain point. And yeah, will always go for the rock band over the orchestra :)

  • matelot

    > I view JavaScript and CSS as base knowledge for any modern developer …You have to know them regardless if you want to build web applications

    huh what ?

  • http://www.guidovo.com Guido

    Enjoyed reading the article. I am currently learning Python by working my way through Learn Python the Hard Way and I thought your comment on not getting distracted going into Django spot on. I tried some things in Django before, but now I also want to focus on getting the hang of Python first.

  • Aputsiaq

    Thanks for sharing. Almost identical situation here, and I have dedicated the next couple of weeks for the same purpose. MIT OpenCourseWare provides several courses, even the most recent courses uses “How to Think Like a Computer Scientist” (the 2002 edition). Just go to ocw.mit.edu and search for “Python”.

  • http://www.curphey.com Mark Curphey

    That’s great. I just created a G+ circle for Python newbies. Let me know if ur on G+ and want to join an informal learning group.

  • http://www.curphey.com Mark Curphey

    Thanks for the comment. Just created a G+ circle for Python newbies / learners. Let me know if ur on G+ and want to join us!

  • http://www.curphey.com Mark Curphey

    Tough to do much on the web without base understanding of both CSS and js

  • http://www.curphey.com Mark Curphey

    Thanks. I think Ruby is a fine choice as well. Good luck and do share any tips!!

  • http://www.curphey.com Mark Curphey

    Thanks for the comment and tip about Wing. I haven’t tried it but will take a look!

  • http://www.curphey.com Mark Curphey

    I did not but will now! Thanks!!!!!

  • http://www.curphey.com Mark Curphey

    I strongly recommend thinking in python. It has a series of exercises after each section that I found really good.

  • http://www.curphey.com Mark Curphey

    Pylons?

  • http://www.curphey.com Mark Curphey

    I haven’t really looked into it. Your take?

  • http://www.curphey.com Mark Curphey

    Thanks mark, always reassuring to see others following a similar approach. Totally agree on teaching. It’s the real leveler on if you actually know the stuff right!!

  • http://www.curphey.com Mark Curphey

    Btw would love to see your capability framework. Would you share?

  • Pete Clarke

    Great article. I’d just started on the Python road when I found this. I’d love to join the G+ circle and interact with similar newbies

  • Kolya Miller

    Awesome post. Resonates with me personally (also almost 40, long distance runner, recently decided to teach myself objective c and develop some apps for the iPhone) – and also resonates on a learning level.
    Did you have a specific project in mind to achieve by the end of the week – or were you just coding different components/bits/algorithms? I found I had to have a target functional application that I was aiming for – that ensured I was focused and learned the bits I needed (while also leaving out some learning for later).
    Again – thanks for sharing!

  • Anonymous

    Hi and thanks for the kind words. I did have a first app in mind (I am looking at building an app that sucks in my Garmin 405CX run data, daily burn food data etc and maps it against a running plan) but didn’t use that in my training as I know there are some tough problems in data manipulation that I wanted to be able to tackle after I got the basics. Also that app will be web based and so Django so again I broke it down and removed the complexity.
    Good luck with your objective C!

  • Iltaren

    much 6 hour to learn core python if you know any other language. they all same.

Panorama Theme by Themocracy