I would recommend Python for a very large range of situations, and I would particularly recommend it for beginners.
For beginners I would point to three advantages:
- It has a relatively small set of legible English syntax, which is easy to learn.
- It has a robust exception model, so you often get to the source of problems immediately.
Python eschews boilerplate, so you won't see phrases like public static void in the code that get glossed over in the accompanying text.
Sugar developers seem to agree with me; Python is one of the main programming languages available on the OLPC Laptop.
For more experienced developers, the main trade-off with Python is that though it runs slow-ish, Python has a reputation for being extremely productive to program with. As a hobbyist programmer, this means reward ÷ effort is high. That keep me programming rather than balking when complicated tasks come up. As a professional, this can give me a competitive edge.
Python is surprisingly good in a wide range of roles:
The secret to good performance is to prototype and prototype, then code the bottlenecks in a faster language. The secret to large systems is to prototype and prototype, until you've got clean separation of the system into managable pieces, then code in whatever language most suits the need of each piece. -- Gordon McMillan, 15 Dec 1999 (found at http://www.mindview.net/Books/Python/ThinkingInPython.html)
There are plenty of good resources for learning Python on the web.
Unfortunately the Python community is (at the time of writing, April 2010) split down the middle into Python 2.x and Python 3.x branches. Migration is slow, as Python 2 and Python 3 are incompatible. For learning Python, this means you have to choose whether to learn the latest Python 3 or the latest Python 2.
Beginners would do well to start with Python 3 now, as it is the new-and-improved version, improved in ways that help to eliminate many stumbling blocks. But you may find yourself having to learn how Python 2 differs to use some libraries or work with existing projects.
More experienced developers should probably jump into Python 2. It may be years before Python 3 is on an equal footing with Python 2, and you don't want to wait that long to be productive.
A Byte of Python - for complete beginners; seems comprehensive and richly sourced (Python 3)
How to Think Like a Computer Scientist - for beginners, more of a teaching aid/lecture notes, but it does go into some foundation datastructures (Python 2)
Improving your Python
Internalise the Zen of Python. Try
>>> import this
Read up on PEP8, Python's manual of style. No matter how strange you find the style it recommends at first, a lot of thought and experience has gone into these guidelines, and once you try them you should soon find your programs easier to read than ever before. Some projects require code/patches to be in strict PEP8 style.
Familiarise yourself with the packages you may not have otherwise come across in the standard library. Some of these provide more elegant solutions to the tasks you might face than what you'd come up with if you didn't know they existed. Some favourites include:
copy - cloning objects, including deep copying (ie. recursively).
optparse - a declarative commandline option parser.
doctest - write example usage in your comments and test that your code obeys them.
multiprocessing - use all your CPUs with relatively little concurrency programming.
traceback - you will need this when writing error handlers
And some particular methods deserve mention
functools.partial() - currying (providing some of the arguments to a function or method, but not calling it)
urllib.urljoin() - expand relative URLs
math.sqrt() - about 10 times faster than ** 0.5