Matt Makai, Python & Java web developer. Washington, D.C.-based Developer Evangelist for Twilio.

Author of Full Stack Python and Coding Across America.

I am @mattmakai on Twitter and makaimc on GitHub.

Learning Python

I am often asked by friends and colleagues that are not currently developers how they should go about learning Python. It's not an easy question - the answer is often highly dependent upon the individual's immediate technical aptitude. I do however believe anyone can learn how to program just as anyone can learn about history or business. The interest in learning to program usually stems from wanting to achieve in one or more of the following goals:

  1. Prototype an Internet-based business idea
  2. Build a new skill set to become a developer
  3. Work better with developers through a greater understanding of their work

This post summarizes the many discussions I've previously so the information can be consumed by a wider audience. I love teaching programming to non-developers so don't hesistant to contact me with further questions.

Where to Start

There's an overwhelming number of resources out there - it's incredibly difficult to know where to begin when you have not done development work before.

My recommendation is to get to a point where you can do "cool stuff" - projects that interest you and will make you want to learn more. The faster you go from forcing yourself to learn to having goals for implementing new interesting ideas, the higher your chances of achieving your goals.

First, get your feet wet. Spend a few hours going through Code Academy's Python tutorials. The great part about using a service like Code Academy is that it's free, structured, has a low barrier to entry, and will teach you some basic concepts that are important in Python.

Local Installation

When I say "local" I mean you want to have Python installed on your computer instead of interacting with it in the browser. This will allow you to start creating website projects.

Get Python on your system. Depending on your operating system, you may already have Python installed. Mac OS X and Linux are good to go. If you're using Windows, head over to Python.org's download page and get Python 2.7. Ignore Python 3+ for now - you can learn it later.

Now go to the command line - on Windows go to Run -> "cmd" and then change directory to C:\Python27\ then type 'python'. You'll get the interpreter you're used to seeing on Code Academy.

On Mac OS X or Linux go to the Terminal and type 'python'. You'll get the interpreter. Again this is great for learning more and running Python on your own system.

Creating a Project

Now that you have Python installed locally you'll want to create a project with .py files so you don't have to type everything into the interpreter.

At this point you'll want to create a subdirectory under your home directory or like C:\devel\ on Windows. Just create some place that you'll remember and can store your files under. Then create subdirectories, such as /Users/johnsmith/devel/blog/ or C:\devel\blog\ for a blog project. Inside that folder you can store your .py (Python) files.

Flask or Django

Flask and Django are web application frameworks. A framework is just code that other developers have written to perform common tasks associated with a given domain. So a "web application" framework is designed to handle all of the common tasks a web application (also known as a website) needs to do, such as:

  1. Authenticating users so they can log in and log out of your site
  2. Storing passwords in a secure way
  3. Accessing the database and then passing that data to the browser
  4. Creating URLs so you can access information at different parts of your website, such as http://www.mywebsite.com/users/ to handle /users/ url

There's a myriad of other things a web framework handles so that you don't have to write that code yourself. Different frameworks such as Flask and Django have different approaches to solving these problems and have varying degrees of difficulty in their associated learning curves.

Once you learn how to use Flask or Django with Python you'll be able to build simple websites. Then you can add complexity and implement the ideas that have been floating around in your head. Eventually you'll reach an "a-ha!" moment where things will click and your productivity will take off. That's when programming goes from being a struggle to actually being fun.

How Do I Learn More Advanced Topics?

By far one of the best resources is Github. Github allows you to read other people's open source code to learn from it. Reading other people's work is very important because you'll learn what makes sense and what can be confusing. Python places a lot of emphasis on language readability and maintainability. You want to embrace that philosophy in the code you write.

An interesting resource I created is a Python topics tree. It gives you a dependency tree for ordering what topics you'll want to learn and in what order for the base Python language. If you find it useful I can create more for topics such as Flask, Django, and other Python libraries.

Next up is a list of resources for keeping you learning. These resources range from general advice on generally learning programming to specific tutorials on web application frameworks such as Django and Flask.

Resources


« Back to blog