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

Python isn't a "MUST Learn" for me, but, as I work with Ubuntu, 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 m 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?

+24  A: 

The official tutorial is great, as is Dive into Python. However, I tought myself by writing an IRC bot.

William Keller
I found DIP very overwhelming... and have also written an IRC Bot too!
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
+55  A: 

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 bots are a good project, as are most small games like snake, tetris etc.

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




Florian Bösch
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](http://corepython.com) 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!
+3  A: 

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.

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

+10  A: 

Dive into Python as well. It's already present in ubuntu hardy installations, so it's very convenient.

The Python Challenge 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.
+2  A: 

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

Another nice resource is the Daily Python URL Daily Python URL

+2  A: 

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

As one resource (for any language), Project Euler 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?"

Michael Easter
+2  A: 

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.

+2  A: 

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.

Jason Etheridge
+3  A: 

My daughter was a TA at MIT for a Intro 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


Are these available online though?
Martin Clarke
+2  A: 

I entered the PyWeek competition. There are countless examples of working Python code for making games at pygame.org. 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  A: 

Python In A Nutshell, 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.

Kevin Little
+23  A: 

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.

Will Hartung
+1  A: 

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.

+3  A: 

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

+2  A: 
Peter Turner
+2  A: 

I've been going through this process recently and have found that beyond the following books, #python on irc.freenode.org 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!


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

+2  A: 

I decided I wanted to create an RPG based on an old pen & paper game but I didn't like dealing w/ 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.


The python manual is just as good as anything else.

Iulian Şerbănoiu
+2  A: 

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

Think Python: An Introduction to Software Design http://www.greenteapress.com/thinkpython/thinkpython.html

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

+3  A: 

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).


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

Niklas Winde

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

Will Harris
  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.

+5  A: 

A lot of our users say that our ShowMeDo Python 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.

Ian Ozsvald

Stanford School of Engineering has some free lectures that go over some python: http://see.stanford.edu/see/lecturelist.aspx?coll=2d712634-2bf1-4b55-9a3a-ca9d470755ee
Lectures 24+


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.

+2  A: 

some free programming books in python

Two others:

NLTK Book - Natural Language Processing using python

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

Gregg Lind

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


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


I've found A Byte of Python 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

No internet connection, and the Python.org Tutorial.pdf.


I'm currently attempting to complete Project Euler in Python. So far I've completed the first 3, 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.