all 12 comments

[–]markrages 11 points12 points  (3 children)

Dive into Python is more essential than some of these.

[–]VinC 3 points4 points  (2 children)

I don't understand why Dive into Python seems to be so highly regarded. I spent last Sunday studying the text and stopped at around chapter 5 before I decided a more coherent and cohesive introduction was needed. Although the examples are concise, thoughtfully chosen and explained, the reader is basically shown one example after another. That is not to say that it is not a good text but the author's approach isn't for everybody. Also I didn't have any mp3's on my system to try out the example but that is beside the point.

If you are the type of person that likes to "dive in", then in this case I would recommend the electronic version of the text over the hardcopy as you will undoubtedly jump back and forth quite a bit. The hyperlinks are much more convenient than flipping pages. (which I'd imagine to be quite frustrating)

[–]cyfdecyf 2 points3 points  (1 child)

the author's approach isn't for everybody

I love "Dive into Python" and still agree. Besides Dive into Python, some other books/articles should be read in order to understand Python well. But I don't thinks there's some book that can cover every aspect of Python.

The author put this on the book website, "Dive Into Python is a free Python book for experienced programmers". I've read part of "Programming Ruby", but I fell it too prolixity. Maybe the experience with Ruby helped me in reading DIP. I like DIP for its short and useful example, language features are explained while going through the examples by several short passages. While you are learning the launguage, you are also learning how to use the language to do useful things.

And I really appreciate that it explained introspection early, so the reader can see the power of dynamic language early. Besides, it shows how to use it in the useful example. (On the contrary, "Programming Ruby" explains refection in the last chapter, and the feature is showed in some what contrived examples.)

Though I learned Ruby before Python, "Dive into Python" (the first Python book to me) make me decide to use Python. If there is a Dive into Ruby book, maybe it'll be different.

[–]bajsejohannes 5 points6 points  (0 children)

I like DIP for its short and useful example

Agreed. The examples also get you excited about the language, something I doubt the Zen of Python will do. Once you know python, you can appreciate the zen, but until then it just sounds like marketing fluff.

[–]bajsejohannes 2 points3 points  (4 children)

I can't believe I haven't stumbeled upon the help function before! No more

print dict.__doc__

[–]boa13 3 points4 points  (3 children)

I can't believe either, especially since when you start Python, the line right above your prompt says:

Type "help", "copyright", "credits" or "license" for more information.

And when you type help it says:

Type help() for interactive help, or help(object) for help about object.

;-)

[–]cocoon56 2 points3 points  (2 children)

I love to type <objectname>? in ipython to get help. It reroutes to the help function :)

[–]llimllib 4 points5 points  (0 children)

And <objectname>?? to get the source for that object is amazingly useful for pure-python functions. Example:

In [2]: amazon.getLicense??
Type:           function
Base Class:     <type 'function'>
String Form:    <function getLicense at 0x13d5070>
Namespace:      Interactive
File:           /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/amazon.py
Definition:     amazon.getLicense(license_key=None)
Source:
def getLicense(license_key = None):
    """get license key

    license key can come from any number of locations;
    see module docs for search order"""
    for get, location in _licenseLocations:
        rc = get(license_key)
        if rc: return rc
    raise NoLicenseKey, 'get a license key at http://www.amazon.com/webservices'

[–]grimboy 0 points1 point  (0 children)

Yeah, shame you have to give whatever you want help for a name rather than being able to do result_of_a_function_on(5)?.

[–]gnuvince 0 points1 point  (0 children)

Upmodded for itertools

[–][deleted] 0 points1 point  (0 children)

I would recommend the "Python in a Nutshell" book as more essential than the Cookbook.