Python is an important programming language to know — it's widely-used in fields like data science, web development, software engineering, game development, automation. But what's the best way to learn Python? That can be difficult and painful to figure out. I know that from experience. One of the things that I found most frustrating when I was learning Python was how generic all the learning resources were. I wanted to learn how to make websites using Python, but it seemed like every learning resource wanted me to spend two long, boring, months on Python syntax before I could even think about doing what interested me. This mismatch made learning Python quite intimidating for me. I put it off for months. I got a couple of lessons into the Codecademy tutorials, then stopped. I looked at Python code, but it was foreign and confusing:

from django . http import HttpResponse def index ( request ) : return HttpResponse ( "Hello, world. You're at the polls index." )

The above code is from the tutorial for Django, a popular Python website development framework. Experienced programmers will often throw snippets like the above at you. “It’s easy!”, they’ll promise. But even a few seemingly simple lines of code can be incredibly confusing. For instance, why are some lines indented? What’s django.http ? Why are some things in parentheses? Understanding how everything fits together when you don’t know much Python can be very hard. The problem is that you need to understand the building blocks of the Python language to build anything interesting. The above code snippet creates a view, which is one of the key building blocks of a website using the popular MVC architecture. If you don’t know how to write the code to create a view, it isn’t really possible to make a dynamic website. Most tutorials assume that you need to learn all of Python syntax before you can start doing anything interesting. This is what leads to months spent just on syntax, when what you really want to be doing is analyzing data, or building a website, or creating an autonomous drone. This is what leads to your motivation ebbing away, and to you just calling the whole thing off. I like to think of this as the “cliff of boring”. You need to be able to climb the “cliff of boring” to make it to the “land of interesting stuff you work on” (better name pending).

After facing the “cliff of boring” a few times and walking away, I found a process that worked better for me. In fact, I think this is the best way to learn Python. What worked was blending learning the basics with building interesting things. I spent as little time as possible learning the basics, then immediately dove into creating things that interested me. In this blog post, I’ll walk you through step by step how to replicate this process, regardless of why you want to learn Python. Step 1: Figure Out What Motivates You to Learn Python Before you start diving into learning Python online, it’s worth asking yourself why you want to learn it. This is because it’s going to be a long and sometimes painful journey. Without enough motivation, you probably won’t make it through. For example, I slept through high school and college programming classes when I had to memorize syntax and I wasn’t motivated. On the other hand, when I needed to use Python to build a website to automatically score essays, I stayed up nights to finish it. Figuring out what motivates you will help you figure out an end goal, and a path that gets you there without boredom. You don’t have to figure out an exact project, just a general area you’re interested in as you prepare to learn Python. Pick an area you’re interested in, such as: Data science / Machine learning

Mobile apps

Websites

Games

Data processing and analysis

Hardware / Sensors / Robots

Scripts to automate your work Yes, you can make robots using Python! From the Raspberry Pi Cookbook. Figure out one or two areas that interest you, and you’re willing to stick with. You’ll be gearing your learning towards them, and eventually will be building projects in them. Step 2: Learn the Basic Syntax Unfortunately, this step can’t be skipped. You have to learn the very basics of Python syntax before you dive deeper into your chosen area. You want to spend the minimum amount of time on this, as it isn’t very motivating. Here are some good resources to help you learn the basics: Learn Python the Hard Way — a book that teaches Python concepts from the basics to more in-depth programs.

Dataquest – Python for Data Science Fundamentals Course — I started Dataquest to make learning Python and data science easier. Dataquest teaches Python syntax in the context of learning data science. For example, you’ll learn about for loops while analyzing weather data.

The Python Tutorial — the tutorial on the main Python site. I can’t emphasize enough that you should only spend the minimum amount of time possible on basic syntax. The quicker you can get to working on projects, the faster you will learn. You can always refer back to the syntax when you get stuck later. You should ideally only spend a couple of weeks on this phase, and definitely no more than a month. Also, a quick note: learn Python 3, not Python 2. Unfortunately a lot of "learn Python" resources online still teach Python 2, but you should definitely learn Python 3. Python 2 is no longer supported, so bugs and security holes will not be fixed!