How I Started Learning Python

Filed in Product & Development by Major Hayden | April 11, 2012 10:00 am

Disclaimer: If you already know Python really well, this post might not be handy for you. However, I’d still love to see your comments and feedback if you have a moment to reply.

Much of my recent work has centered on OpenStack[1] and I’ve found myself overwhelmed by learning Python. Although I don’t have any formal education on anything related to computer science or programming, I’ve worked my way through PHP, Perl and Ruby.

Ruby seems to be the most comfortable language for me to use due to the simplicity of the syntax and the handy features provided by the standard libraries and common gems. Python always caught me as strange due to the forced indenting[2] (I indent my code properly anyway, but it still feels weird to be forced to do so), module namespaces[3] and the overall syntax[4]. Things like list and generator comprehension[5] made my head spin and I avoided Python like the plague.

All of that had to change over the past few months. I’m not an expert in Python by any means but I’ll be glad to share with you how I trekked from the depths of Ruby to the edge of Python.

Learn Python The Hard Way

Zed Shaw’s guide to learning Python[6] has been the primary recommendation from every Python developer I’ve polled at Rackspace. It is clear, concise and accurate; however, I never did finish the HTML guide. Something would end up distracting me or I’d become discouraged by something I couldn’t understand.

That’s when I found the video course on Udemy[7]. The video course costs $29 and comes with the PDF copy of the book. You can watch Zed work through the problems on screen via an easy-to-follow screencast. He even makes common errors on screen and runs the interpreter so you can get familiar with exceptions from common typos.

Python Documentation

If it’s in Python or the standard libraries bundled along with it, it’s in the Python documentation[8]. There are plenty of code examples for almost all of the methods from the standard libraries on the site. It’s a good resource to bookmark while you’re learning what certain methods do and which parameters they expect. You can also ensure that your code isn’t importing modules that are deprecated.

Stack Overflow

This could draw criticism from some, but Stack Overflow[9] is a good resource to find better ways to do things in Python. I’ve written some pretty ugly Python code only to find that I could have called a couple of methods from modules found in Python’s standard libraries. You can find lots of examples of code simplification and recommendations for which modules to use for a particular project.

Keep in mind that some suggestions on the site can be subpar. Some may contain deprecated or insecure code that could hurt your project’s success. Be sure to look through the comments after each answer to ensure that you’re reading a solid solution.

Coworkers And Colleagues

Some of the best resources for learning Python are probably all around you in your office or online. I’m extremely fortunate to be surrounded by gifted and experienced developers at Rackspace who genuinely care about their work and want to share their strategies with others. I’ve always had a tough time understanding lambdas[10] (I couldn’t understand them in Ruby, either), but one of my coworkers took me through some examples as I was leaving work.

If you feel like you might be a bother to your coworkers, try to do some homework on the topic first or give them a specific example of what you’re trying to solve. It will show them that you’ve done your best to understand the topic but that you need some help getting over the hump. A hot cup of their favorite coffee or snack doesn’t hurt either.

Just Try It

Find a problem, make a project and write some Python. Most of us have something we’d like to accomplish if we had the time. Take that idea or problem and write Python to solve it. You’ll pick up new knowledge as you work through the project and you’ll probably back yourself into a corner more than once. When it happens, go back to the documentation, do some Googling[11] and lean on your peers.

I’ve been working with Python for just over a month and these strategies have jump started my learning by leaps and bounds. If you’re struggling, drop me a line and I’ll see what I can do to help. I’m also eager to hear your strategies for learning Python so they can be shared with others.

  1. OpenStack:
  2. forced indenting:
  3. module namespaces:
  4. overall syntax:
  5. list and generator comprehension:
  6. guide to learning Python:
  7. video course on Udemy:
  8. Python documentation:
  9. Stack Overflow:
  10. lambdas:
  11. Googling:

Source URL: