Advertisement

The Best Way to Learn Python

by
This post is part of a series called The Best Way to Learn... .
The Best Way to Learn JavaScript
The Best Way to Learn Ruby on Rails

Python is more popular than ever, and is being used everywhere from back-end web servers, to front-end game development, and everything in between. Python is a true general purpose language and is quickly becoming a must-have tool in the arsenal of any self-respecting programmer.

But Python isn't popular just because it's popular. It is easy to learn, reads like pseudo-code, and is wickedly agile. However, learning any new language can be a daunting task, and finding the right places and people to learn from is half the battle. That's where this guide can help. This is your blueprint for making Python easy, fun and rewarding to learn.


Assignment 1: Start With the Basics

At the time of this writing, there are two main versions of Python in circulation: Python 2.7 and Python 3.2. Which you choose to learn really doesn't matter too much, as the differences will be minimal—especially to a beginner. But you should know that, while Python 2 has far, far more 3rd party support, Python 3 is the primary focus of the developers designing the language. The choice is yours, but if your code acts differently to any given tutorial, make sure you use the same Python version used in the tutorial.

Wikibooks' Non-Programmers Tutorial for Python

Wikibooks is always a great source to learn something new, and Python is no exception. Here you will find a solid and to the point series of guides that will teach you the ropes of Python. It doesn't get too technical, and you can jump into coding something somewhat useful and rewarding pretty quickly. Because of this, I recommend this site as the best place to start on your Python journey.

The Official Python Tutorial

You won't find a better source of information than the official python.org documentation. However, if you want to jump right in, as I'm sure many of you will, this might not be the best place to start.

The content tends to be more technical than wikibooks, which will be helpful later on as you progress through the language. But, for a beginner, it may just get in the way of what really is a very simple and beautiful language.

For beginners, the biggest difference between Python 2 and Python 3 will most likely be that Python 2 can use print without parentheses. Python 3 requires parentheses, but that's all.


Assignment 2: Tutorials and Screencasts

TheNewBoston's  Python Programming Tutorials

TheNewBoston's playlists are always great, and you can learn a whole host of languages. ‘Bucky' is a great instructor because he strikes a really great balance between being funny while also being easy to listen. I highly recommend any of his playlists—especially his Python playlist. He assumes zero prior knowledge of programming and will leave you with a firm grasp of the language.

Nettuts+'s Python from Scratch

A little closer to home is Giles Lavelle's intro to Python. Like TheNewBoston's series, Lavelle also assumes zero prior programming experience.

If you want to see some real-world applications of your applications, or would like to aim towards web development with Python, this series might be the one for you.

The screencast takes you from nothing to building a dynamic website using a Python web framework called Django.

ShowMeDo's Python Screencasts

StackOverflow isn't just full of 'newbie' errors and problems.

ShowMeDo has a huge catalogue of Python related videos. While it may not be the most user friendly experience around, the videos range in level from absolute beginner to the most advanced Python techniques. It is well worth checking out.

Build a Python Bot That Can Play Web Games

This tutorial is pretty specific in terms of what you're going to learn, and I do not recommend it for a complete beginner. I feel, however, that it's worth a mention. In this guide, Chris Kiehl shows you how to build a very interesting Python bot that will play a simple game for you. The tutorial really goes to show the power of Python; it can be applied to do everyday repetitive tasks that you may have on your computer.


Assignment 3: Free e-books!

Its hard to beat a good book when your trying to learn something new, and with the great community that has developed around the Python language, there is a plethora of free high quality e-books to choose from. Below is a quick list of some of the best. You can download a free e-book version for each of them, or you can choose to buy the physical book (or donate) if you want to support the author, which I'm sure they would greatly appreciate.

Learn Python the Hard Way

Despite the name, Learn Python The Hard Way makes learning Python incredibly easy—the way it's meant to be! In this book, Zed A. Shaw works from the ground up giving you a detailed and comprehensive guide to Python without getting in your way of the actual coding. Shaw is informal but thorough, making the book an easy but rewarding read.

Think Python: How to Think Like a Computer Scientist

You won't find a better source of information than the official python.org documentation.

As the sub title might suggest, “How to think like a computer scientist”, Think Python stays a little more towards the theoretical side of things. This may prove a little frustrating for a total beginner, but the book is well worth the read in regards to algorithm theory and high level concepts.

Invent With Python

If ‘learning by doing' is your thing, then building your own game will prove to be a rewarding experience! In this book, Al Sweigart assumes no prior knowledge of Python and takes you all the way to building your own game. Given that the book is geared towards game development, the book may move a little quickly for a total beginner. Later on in this article, I mention a similar book of his where he assumes a prior knowledge of Python. If you feel you are have a good grasp of the language, then his other book might be a better resource for you.

The Django Book

If you want to learn Python for web development, then you're probably going to be using the Django framework. This book assumes fluency in Python, but it teaches Django as if you are a beginner to the framework. The Django Book is as good as they come and will be invaluable for any budding web developer.

Python Books

If you don't have enough to read yet, or want a book on a specific topic, then you should follow this link. The folks over at python.org have complied an extensive list of books, sorted by difficulty and topic.


Assignment 4: Get Familiar With StackOverflow

Thousands of developers have experienced every problem that you are bound to face. StackOverflow is a great resource where developers find solutions to their problems. When you happen upon an error that you're not sure how to fix, search StackOverflow. You will more than likely find a solution and how other people solved their problem.

But StackOverflow isn't just full of 'newbie' errors and problems; there are some really clever and helpful people that use the site - learn from them!

Take a look at the Hidden features of Python thread, for example.

Many of the tips and tricks you see here may not be covered in many formal tutorials, but they will be extremely helpful for intermediate to advanced Python users.


Assignment 5: Project Euler

Project Euler (pronounced ‘Oil-er', to save you some embarrassment later on) is one of my favorite websites. After making an account, you can work through the ~400 problems on the website. Each problem is about 50% mathematics and 50% programming and, in my opinion, the most rewarding way to learn more of either subject.

The problems start off easy to test your knowledge of the language, but grow in difficulty to challenge even the most seasoned programmers. Eventually, the difficulty of the problems will force you to find the most efficient algorithm - that is if you don't want to wait hours to compute the answer.

Nothing will turn you into a programming wizard more quickly than pushing yourself for the fastest and most efficient solutions to the Project Euler problems.

When you crack a new problem, you gain access to that problem's forum thread where many people discuss their solutions and ideas with one another. Many of the solutions in later pages of the thread will be in Python. This is really the key to growing your programming prowess. If there is someone with a solution that is faster than yours, take the time to analyze it to see where you could improve your own solution. Over time, you will pick up all the tricks of the trade and grow your Python knowledge in a meaningful and rewarding way.

Additionally, there are also some really great blogs that work through the Project Euler problems in Python. If you are stuck on a problem, there is no shame in having a sneak peak at other developers' work, as long as you intend on learning from it. Here are two of my favorite:


Assignment 6: Build a Game

Few things are more satisfying than building your own game.

Few things are more satisfying than building your own game. It can be a steep learning curve, but well worth it and very rewarding. PyGame is the best known game library for Python, and you will be able to find many free tutorials on it. Here are some of the best PyGame tutorials. 

Official PyGame Documentation

As with the case of the original Python tutorials, the developers of PyGame also have their own intro documentation. But these may be overly technical if you want to jump straight in and start building your game. Developer documentation, however, will always be your best source of information; so, I still recommend you get familiar with the site.

Invent With Python (With PyGame)

This free e-book by Al Sweigart runs through the PyGame library, taking you from zero knowledge to building a couple of games for yourself. The simple games will provide you with a perfect platform to start your own projects, if you are so inclined. Sweigart provides extensive and detailed comments throughout all of his code to help you learn as you go.

TheNewBoston's Computer Game Development Tutorial

This is another Playlist from TheNewBoston. It serves well as an intro to PyGame. It assumes zero knowledge and gives you a good feel for the PyGame library, but unlike the InventWithPython guide, it is more to the point and won't bring you to making your own full game.


Assignment 7: Get to Know Some Common Libraries and Tools

Python is a general purpose language that can do almost anything; so, of course, there is a seemingly endless supply of libraries and tools out there. Here are some of the most popular.

PyPy

If you ever want to scrape a HTML for some information... BeautifulSoup will do all this for you and add years to your life.

If you are doing some CPU intensive work, and you find that Python is proving itself to be a bottleneck, then maybe you need PyPy. PyPy is an alternative compiler for Python that can really speed up your processing.

NumPy + SciPy

These two usually go hand in hand (SciPy is dependent NumPy). If you are doing some serious number crunching for mathematical or scientific research, then these two libraries will be your best friends. NumPy and SciPy extend the mathematical functions and capabilities of Python and can greatly speed up some of your tasks.

BeautifulSoup

BeautifulSoup really is beautiful. If you need to scrape a HTML page for some information, you will know all too well the frustration and hair loss that it can bring. BeautifulSoup will do all this for you and add years to your life. Highly recommended and fun to play around with.

Python Image Library

The Python Image Library (PIL) is an extensive library that is great for anything to do with images. If you need to manipulate an image, chances are PIL can do it for you.

Django

As mentioned previously in the article, the Django framework is what you will probably use if your aim is web development. It is the most common web framework for Python and also has the most learning resources available.


Assignment 8: Get Involved in Open Source Projects

After you have a decent grasp of the language, being able to read and understand other people's code is always an important skill to have - not to mention that it is a really great way to learn too.

For this reason, open source projects are great. Github or Bitbucket are the to go-to places for this. Don't worry about people judging your code, you don't have to contribute right away. You are always free to fork a project, tinker with it yourself, and see how things work. If you do happen to see something that you think could be improved, great! Go for it and submit your improvement. That's what open source is for.


Conclusion

I hope I have been able to provide a solid base of Python knowledge for you. If there are other places of interest that you think should have been included in this syllabus, let me know in the comments below to help others out!