Stack OverflowWhat did you use to teach yourself Python?
[+84] [34] Mez
[2008-09-21 19:40:59]
[ python ]

I'm an avid programmer, and I like to learn new languages. I normally teach them myself.

Python [1] isn't a "must-learn" language for me, but, as I work with Ubuntu [2], and a lot of their own code is now Python based, it'd be useful for me to learn, so that I can work with their code. I already know the basics of programming (and the advanced) and am versed in multiple programming Languages.

What are your suggestions for resources for learning Python, or how would you start working with Python to get yourself to a competent level with it?

[+86] [2008-09-21 19:42:38] Florian Bösch [ACCEPTED]

The best way to learn Python (or any programming language) is to pick something you want to do and start doing it in the language you want to learn.

Pick anything that interests you and is slightly more complex then a simple Hello World. IRC [1] bots are a good project, as are most small games like Snake [2], Tetris [3], etc.

For Python there exists a wealth of information both online and in dead tree form:





I would add to this that many products (FOSS and commercial) are starting to use Python as their plug-in/scripting language of choice. If any of your tools use Python, that's the perfect way to learn. - James Schek
please add my book Core Python Programming to the dead trees section... it's been very well received for the past 11 years, and i am in the research phase for a 3rd edition! - wescpy
Perhaps it's misplaced for your list, but for myself to learn Python I took the llama book "Learning Perl", and did all the exercises in Python. Perl & Python are so similar that the exercises translated over very well, and the book is simply one of the best introductory programming texts I've ever seen. - Adam Parkin
a big +1 for 'dive into python'. really great intro into how to think pythonically. until i read that book i was just doing things in a C/Java style way, which doesn't really jive well with python in terms of readability or efficiency - Claudiu
[+36] [2008-09-21 21:14:21] Will Hartung

Learn it the way you learn any other language. Write a program in it. Any program. Some program that is interesting to YOU. Doesn't have to be a huge project, but it should be a couple hundred lines of code. Something more than "Hello World".

No reason to try and "learn Python" unless you have some specific goal. Rather take the goal, and apply Python to it.

What will you end up with? Most likely you will end up with "C in Python" or "Java in Python", or "FORTRAN in Python". That is, whatever language you're comfortable with now will influence how you write your early Python programs. "When I want to do X in language L, I do Q. How do I do Q in Python." Which completely side steps whether doing Q in Python is a good idea in the first place.

In the end you won't be creating "idiomatic" Python code, rather you'll create working Python code, using idioms and constructs that YOU are already comfortable with while at the same time learning the Python runtime, syntax, and other boiler plate that surrounds a language.

At the same time, inevitably, some Python idioms will "sneak" their way in to your code. It can't be helped. This casual exposure of system to your way of thinking is what makes it easier to apply, because you're applying the new constructs in a domain you're familiar with.

Now, once you've finished your first project, you can start your second. Only now the fundamentals of Python are much more clear to you. In the second project, the fundamentals become second nature and now you can try and stretch to create "idiomatic" Python. Basically, now you can write "Python in Python".

Inevitably, later, when you go back to some other language, you may start trying to write "Python in Java", or something similar. Some will take, some won't. Some will be very difficult and not worth the effort, other effects may surprise you.

But starting blind, with just a language book, for me, had never worked well. I know how to program, I just need to know how to program in the L language. Rather than starting from scratch, apply the knowledge you already have and you'll end up have quicker success in the short term, and a better foundation to really learn the language in the long term.

[+26] [2008-09-21 19:42:38] William Keller

The official tutorial [1] is great, as is Dive into Python [2]. However, I taught myself by writing an IRC bot.


I found DIP very overwhelming... and have also written an IRC Bot too! - Mez
Dive into Python is good for people who are already very familliar with programming. IRC bots are a great learning project, even though there are better libraries for "real" projects, writing an IRC bot covers so much ground that it helped me learn much of the standard library. - William Keller
[+13] [2008-09-21 19:46:40] Kaushik

Dive into Python as well. It's already present in Ubuntu 8.04 [1] (Hardy Heron) installations, so it's very convenient.

The Python Challenge [2] is a very pleasant way to get used to programming with Python. You also get to try some quirky puzzles, so it's quite enjoyable.


The Python challenge is interesting! Very recommended! - Kenny M.
[+8] [2008-09-21 23:34:49] S.Lott

I learned Python by doing lots of small projects. See Building Skills in Python [1] for lots and lots of exercises.


[+6] [2008-09-22 17:08:09] Ian Ozsvald

A lot of our users say that our ShowMeDo Python [1] tutorials are very helpful. There are 355 videos as I write this, with more open-source tutorials added each week.

All sorts of topics are covered, Python code is written and discussed whilst you watch leading you up to working examples.

Disclaimer - I'm a co-founder of ShowMeDo.


[+5] [2008-09-22 09:40:20] e-satis

Well, there are great resources for advanced Python programming:

Here is a list of subjects you must understand if you want to master Python:

  • list comprehensions
  • iterators
  • generators
  • decorators

They are what make Python such a cool language (with the standard library of course, that I keep discovering everyday).


[+4] [2008-09-21 20:09:25] Metro

My daughter was a TA [1] at MIT [2] for a introduction computer class that used Python. I worked through their weekly programming assignments.

Here is a link that has the course's assignments for the semester before my daughter TA'd it.

6.00 Introduction to Computer Science and Programming [3]


(1) Are these available online though? - Martin Clarke
[+4] [2008-09-21 20:44:06] Kevin Little

Python In A Nutshell [1], by Alex Martelli. For an experienced programmer this is the best way, IMHO. Good, compact, to the point. In Martelli's case, pretty well written, too.


[+3] [2008-09-21 19:46:13] Sean

I agree with William Keller; use the tutorial to get your feet wet (it's short) and then read Dive Into Python or a Book, whichever works for you, as you begin your own project. At first, just to get the hang of the Pythonic style of doing things, check out all the great projects tagged with Python at Google OSS project hosting [1].

If you get stuck, you can normally get answers within seconds at the Python IRC channel [2] on freenode.


[+3] [2008-09-22 06:58:48] brendonh

One of the standard recommendations over on Freenode's #python is:

Think Python: An Introduction to Software Design

It's free, comprehensive, has lots of exercises, and tries to teach the Python mindset as well as the syntax.

[+3] [2008-10-08 20:43:51] Gregg Lind

Some free programming books in Python [1]

Two others:

NLTK Book [2] - Natural Language Processing using Python

Invent Your Own Computer Games With Python [3] - a kid-focused book on implementing Tic-tac-toe and other simple console based games. Very readable and easy even for an inexperienced programmer.


[+2] [2008-09-21 19:49:26] user18044

Lurk on the Usenet group for Python: Google groups [1]. Lots of interesting topics and good explanations.

Another nice resource is the Daily Python URL Daily Python URL [2]


[+2] [2008-09-21 19:53:29] Michael Easter

As mentioned, find some interesting problems (small is better), and jump in.

As one resource (for any language), Project Euler [1] might inspire with some neat problems.

Another idea is to implement some of the classic data structures (e.g. Red-Black tree, or a priority queue).

I have come to love Python but won't deny that there were some frustrations at the start, as with any language. However, I do think that it is fairly easy to "get" the Python philosophy, because it is so intuitive and fluid. It may take time to become truly Pythonic but it doesn't take long to ask "which is closer to the Pythonic ideal: solution A or solution B?"


Honestly I found Project Euler to be far more of an exercise in mathematics than in programming. - Adam Parkin
[+2] [2008-09-21 19:57:23] tim.tadh

The book I used was Core Python Programming by Wesley J Chun. I believe it is a second edition now. I really liked it. I also have the Python Cookbook for a reference on how do specific tasks. The python library documentation is also really helpful. The best online community I found is the Python usenet group comp.lang.python.

UPDATE (Mar 2012): Part II of Core Python Programming ( is now available in a 3rd edition: however keep in mind that this book is for existing Python programmers who've learned the basics and want to move to the next level. The 2nd edition is still the my best book for programmers new to Python -- to extend its life in 2009, I added new appendices for 2.6 (also some 2.7 stuff) and 3.x. - wescpy
[+2] [2008-09-21 20:01:02] Jason Etheridge

I found the official tutorial to be sufficient. After that, I've only needed to refer to the library reference. Once the Pythonic way of doing things sinks in--and it really is intuitive, which is what makes the language such a joy to use--you find you don't need additional coaching.

[+2] [2008-09-21 20:26:55] postfuturist

I entered the PyWeek [1] competition. There are countless examples of working Python code for making games at [2]. All the games from previous PyWeek entries are available with source code on the webpage, too. I learned a lot from looking at some of those entries. Having the time limitation encourages you to dig in, solve problems, and learn Python basics.


[+2] [2008-09-22 01:54:40] Peter Turner

I don't think Python really requires reading anything at all, just think of something you want to do and do it in Python. When you hit a brick wall, search the documentation.

I'm not saying that the official documentation is helpful at all, but they help you piece together what you're trying to do.

Anyway, that's how I learned my share of Python, albeit a small one.

[+2] [2008-09-22 04:30:36] Crad

I've been going through this process recently and have found that beyond the following books, #python on to be very helpful.

  • Python - Essential Reference 3rd Edition by Beazley
  • Python in a Nutshell by Martelli

I use both books, while they're both similar, they touch on topics in slightly different ways.

I have found the best way to learn is to pick an application idea and bang my head against it with the various resources until I get it to where I want it. If it's something I plan on releasing with an open license, I've found asking #python on freenode to do code review as very helpful and enlightening. Good luck!

[+2] [2008-09-22 06:14:20] crystalattice

I decided I wanted to create an RPG based on an old pen and paper game, but I didn't like dealing with the idiosyncracies of C/C++. I had heard that Python was a good language so I decided to learn Python so I could write the game.

If you don't have a real need to learn a language, it will be difficult. Though it's old (Python 2.2), I would recommend getting a copy of Dietel & Dietel's "Python How to Program" book. It's structured like a college text book so it provides many different types of programs to write, from simple scripts to actual "real world" programs.

My usual way to get a basic understanding of a new language has been to implement the rules of tabletop RPGs. I've used that method Forth, Lisp, C++, Java, Python so far. 'Dive into Python' is also a good book for learning Python. - LAK
[+1] [2008-09-21 21:27:24] stalepretzel
Project Euler is a great place to practice programming. It is a site full of math/programming problems, and Python is a great language to use to solve them. I got significantly better at python by using project euler.

I disagree that P.E. is a great place to practice programming. The challenge of the site is recognizing mathematical "tricks" rather than in learning the ins & outs of a language. If you're a "mathy" type person then it may be fun, but for the typical layman who cringes at the thought of doing tough math puzzles it's just an exercise in frustration. - Adam Parkin
[+1] [2010-11-05 13:08:30] subeen

I used the book 'Dive into Python' while learning, and I think it's a good one for experienced programmers. But recently I have found Google's Python Class [1] which should be very helpful for beginners.


[0] [2008-09-22 05:59:38] Alvin Delagon

Dive into Python and by looking at other people's code.

[0] [2008-09-22 06:49:14] INS

The Python manual [1] is just as good as anything else.


[0] [2008-09-22 09:44:49] Niklas Winde

I am currently implementing Conway's Game of Life [1]. It's pretty cool because it forces me to try some GUI packs for Python at the same time.


[0] [2008-09-22 09:49:35] Will Harris

I learnt the basics from Programming Python by Mark Lutz. Then I spent a few years programming Python in my day jobs.

[0] [2008-09-22 09:55:27] Vasil
  1. Start solving real problems.
  2. Read other people's code.

While i did read random chapters from a variety of books, most of what I learned was from the sourcecode of various frameworks (i.e. Django, Twisted). One of the greatest things about Python is that code is easy to digest 99% of the times.

[0] [2008-09-22 17:12:27] Joshua

Stanford School of Engineering has some free lectures that go over some Python: Introduction to Computer Science | Programming Paradigms [1]

Lectures 24+


[0] [2008-09-22 22:34:20] Dan

Another vote for Dive Into Python here! What I most appreciate about it is that it goes beyond merely teaching you the syntax, to teaching you the basic "idioms" of Python programming so that you can write code in a style that is efficient and Pythonic.

After you've mastered that, O'Reilly's Programming Python is an excellent, excellent reference and guide to all the cool things you can do with Python, especially web and database programming.

[0] [2008-11-27 04:08:43] M. Utku ALTINKAYA

I have learnt Python while trying to do the right thing with other languages.

[0] [2008-11-27 04:25:12] humanlever

I've found A Byte of Python [1] by Swaroop C H, to be the most useful resource in laying out and explaining the fundamentals of Python in terms that mortals can understand.


Ditto :) I'd just added the same link, only to realize that this one was on page two of the comments. Very good book. - Mike Wagner
[0] [2008-11-27 05:24:07] dbr

No Internet connection, and the Tutorial.pdf [1].


[0] [2010-03-09 22:55:17] glasnt

I'm currently attempting to complete Project Euler [1] in Python. So far I've completed the first three, and learnt Python's methods of ranges, for statements, variable assignment, bool logic, output, loops, indentation nazi-ism, and commenting.

I come from a heavy Java/database background, and I'm sure I could do a lot of the Euler problems in Java, PL/SQL or Excel, given I know programming structures and problem solving, but I want to challenge myself with a new language.

It's like trying to converse to someone in French even though you know a lot of English, and they know English and French.


[-1] [2008-11-26 03:31:20] crystalattice

Well, to put in a blatant plug, I'm writing a Intro to Programming book [1] using Python. It's an ebook and will be free, if cost is a concern.


Just wanted to let everyone know that my book is completed and available in both print and electronic versions. Free copies are still available for download. - crystalattice