Forgot your password?
typodupeerror
Image

Learning Python, 4th Edition 163

Posted by samzenpus
from the read-all-about-it dept.
thatpythonguy writes "Learning Python is a well-written book by an experienced Python trainer that has served the Python community well since the first edition was published in 1999. Now, at its fourth edition, this book by Mark Lutz arguably continues to be Python's bible." Read on for the rest of Ahmed's review.
Learning Python, 4th Edition
author Mark Lutz
pages 1216
publisher O'Reilly Media
rating 9/10
reviewer Ahmed Al-Saadi
ISBN 0596158068
summary A hands-on book that will help you be productive with Python 3.0 quickly
This book is addressed as an introductory text to programmers new to Python. Although people with no programming experience are not discouraged from reading it, they are warned that time is mostly spent teaching Python, not programming fundamentals. I agree with this picture, though from my own experience and those of others, the book is equally valuable to more experienced Python programmers both as a pseudo-reference and as an introduction to more advanced topics. The critical point here is that the book does not make assumptions about educational or vocational experiences and provides many examples; this renders the book approachable by a large audience.

Both Python 2.6 and 3.x are covered in this edition. However, the latest 3.x line is considered the reference from which variations in 2.6 are discussed when appropriate. This approach is logical; the new Python 3.x presents a major change to the language, but is not sufficiently dominant to warrant exclusive treatment.

This book discusses the Python language and excludes the Python standard and non-standard libraries. The latter are discussed in other places including Lutz's own Programming Python which stands at its third edition at the time of writing of this article. I find this division necessary because of size considerations and, in fact, this division did not exist in the first edition of the book! However, there is one topic that does not seem to fit the language/libraries divide, and that topic is packaging and deployment.

I will argue that there are not many (if any) books that discuss packaging and deployment of Python programs well. I will also argue that this topic should be included in the book being reviewed here since it is so essential to real Python programming. Since Lutz discusses the Python runtime environment, I do not think it detracts from the book's coherence to include a chapter on packaging.It is possible that the proliferation of various packaging and deployment options such as distutils, setuptools, pip, buildout, virtualenv, paver, fabric and others, is the reason for this exclusion. Or it could be that these tools are in a state of major flux that any text will become quickly outdated. If size is the reason for this exclusion, maybe Lutz or someone else can publish 'Packaing and Deploying Python' as a separate volume.

The book starts by building a case for the use of Python. Both the features of the language and its prominent users are discussed to build credibility. Then, the runtime environment is discussed: how to run programs in various ways on various operating systems and language interpreters.

Types and statements, which are at the core of any language, are discussed next. Notably, there is an excellent discussion of the topic of iterators and generators (also discussed in a later chapter). Functions, modules and classes are then introduced. The text also includes a discussion of general object-oriented programming (OOP) principles which I find to be invaluable as it brings the topic of classes to life.

Exceptions are introduced and discussed in detail. The placement here is appropriate since exceptions are now objects in Python so classes had to be discussed first. This chapter should prove to be especially useful for people migrating from other languages that do not have simple, yet effective, exception-handling constructs.

Finally, four advanced topics are covered: decorators, Unicode, managed attributes, meta-classes. I find the first two to be absolutely necessary for almost any system nowadays, even small ones! The atter two are not as ubiquitous, but should be useful to more experienced programmers.

I should mention here that the discussion of the topics discussed above does not stop at the basics but provides comprehensive coverage. This is evident in the discussion of concepts such as dynamic typing, inheritance order, iterators, generators, comprehensions, and functional programming, among many others. There is even an interlude on documentation and the pydoc library.

Like many programming texts, the book uses small programming examples (appropriately executed in the Python interactive shell). The small examples hope to capture the essence of the topic at hand, and that, it does well within the limitations of a small-scale context. But this fourth edition adds a new chapter on classes (Chapter 27) that contains a more realistic code example presented in a tutorial format.

In addition to examples, each chapter ends with a summary of the chapter's content as well as a quiz on that content. The quiz is immediately followed by its answers for easy reference. I have to admit that I do not use any of these two features, so I will not be able to comment on their efficacy.

Like many O'Reilly books, this is a well-written, coherent, and beautifully type-set book. I highly recommend it to anyone who wants to, or already does, program using python. It should help the novice in the transition to an excellent programming language or, otherwise, make an already familiar environment more powerful in the hands of veterans.

Ahmed Al-Saadi is a Software Analyst who works for a Montreal Python house. He wrote his first lines of code on a Sinclair ZX Spectrum+, though unfortunately not in Python at the time.

You can purchase Learning Python, 4th Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

*

This discussion has been archived. No new comments can be posted.

Learning Python, 4th Edition

Comments Filter:
  • Re:Cover art (Score:3, Informative)

    by DragonWriter (970822) on Monday February 22, 2010 @05:17PM (#31235974)

    Soooo the language is called PYTHON and O'Reilly put some kind of rodent on the cover? Not, I don't know... a python?

    They put a different animal on the cover of each book.

    The python is, IIRC, on the cover of Programming Python.

  • Re:Cover art (Score:4, Informative)

    by theskipper (461997) on Monday February 22, 2010 @05:26PM (#31236152)

    A python appears on a previous O'Reilly book, "Python in a Nutshell" (ISBN 978-0-596-10046-9).

    My assumption is that they don't use the same animal on more than one cover, correct me if I'm wrong.

  • Re:Cover art (Score:3, Informative)

    by gpuk (712102) on Monday February 22, 2010 @05:43PM (#31236468) Homepage

    IIRC, the python name is a homage to Monty Python and has nothing to do with the snake. Perhaps a knight sans arms would have been more fitting...

  • Too wordy (Score:5, Informative)

    by milgr (726027) on Monday February 22, 2010 @05:48PM (#31236564)

    I bought this book about a month ago. I had my doubts about a book this size, and my doubts were realized.

    I learned C from K&R first edition. K&R is about 150 pages (from memory). It covers all of the language succinctly and completely. Actually, it covers most of the language twice - first in tutorial form then in specification form. It is a fine resource.

    Why should a book on Python be over 1000 pages? I started reading this book the same way I read K&R - from the beginning. Unlike K&R, after 50 pages I barely got to coding. Within each section the language is quite verbose. I suspect that the authors were paid by the word or the page.

    On a positive note, I was able to use this book as a reference book as the index is quite reasonable.

    I would recommend this book to those insomniacs who are interested in learning Python.

  • Re:why? (Score:4, Informative)

    by mangu (126918) on Monday February 22, 2010 @05:54PM (#31236720)

    I know you are trolling, but here's the answer:

    1) Programming in Python is faster than in C, and Python lets you use C libraries where performance is needed. Python will not make C go away, but will let it be used where it's really needed.

    2) Python is more secure and much more powerful than PHP. With a programming environment like Django, Turbo Gears, or Zope, Python can easily do anything PHP can, but PHP is not even near to doing everything Python can do.

  • by kpainter (901021) on Monday February 22, 2010 @05:57PM (#31236764)
    Programming in Python 3: A Complete Introduction to the Python Language by Mark Summerfield is better IMHO.

    I gave up in the middle of Learning Python 3rd Ed. One of the things I absolutely hated about Learning Python is the author continually telling you about X will be covered later in chapter Y. There is a LOT of that. That and half-way through the book, I still couldn't do anything simple as he hadn't even talked about for loops yet. Too much detail on the finer points of data types and too little "quick start". I got bored with this book.

    I don't doubt that there is a lot of great info in that book. It just isn't organized very well at all. My guess is the 4th ed. is changed to reflect Python 3.x. If it were reorganized, it would probably be really good.

  • by slimjim8094 (941042) <slashdot3 AT justconnected DOT net> on Monday February 22, 2010 @05:59PM (#31236836)

    I have probably the previous edition of this book, and what you're describing sounds like a different book. Lamda expressions came after basic and intermediate functions - I had no problem with it. All he talked about was idiom - the "pythonic" way of doing things - while mentioning that a C programmer would probably have used a loop instead of a map expression, etc.

    So I'd say they fixed it up a bit.

  • by navyjeff (900138) on Monday February 22, 2010 @06:05PM (#31236948) Homepage Journal

    I found Python to be a useful language for scripting and accessing C libraries.

    One of the things I like most about it (and others seem to hate) is that it's sensitive to whitespace. This feature has the side effect of making the language more readable and forcing people to indent their code. After programming in Perl, did you ever go back and try to figure out what you did a year ago? I find that my year-old Python programs to be much more readable than my year-old Perl.

    Also, if you're a scientist or engineer, I recommend "Python Scripting for Computational Science". It will get you programming much earlier than Learning Python and is oriented toward mathematical calculation and visualization problems.

  • by Manhigh (148034) on Monday February 22, 2010 @06:10PM (#31237028)

    While I cant speak to php or Occam...

    You aren't forced into object orient programming as with Java, although the language does have good implementations (IMHO) of classes if you choose to utilize them. It also doesn't force the 'one class per file' structure of Java upon you. (Granted its been years since I've touched Java, so these critiques may no longer apply).

    I started by using Python for a lot of the things for which I initially used Perl. I find Python code immensely more readable than Perl.

    Lately I've used Python alot because it has some superb 3rd party libraries for scientific computing (numpy, scipy, matplotlib are the three which I use the most.) These libraries give Python the utility of Matlab (vectorized functions, easy plotting, interfacing to C and Fortran for speed) in an open platform without the fees associated with Matlab.

    For my job (aerospace engineering) Python is now my go-to language when I first start working a problem, and I transition to C or Fortran only if I need the speed or someone else requires me to do so, which is not often these days.

  • by steve.howard (988489) on Monday February 22, 2010 @06:27PM (#31237278)
    http://diveintopython3.org/ [diveintopython3.org]

If money can't buy happiness, I guess you'll just have to rent it.

Working...