
Learning Python, 4th Edition 163
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.
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.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 |
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.
Cover art (Score:2, Insightful)
Soooo the language is called PYTHON and O'Reilly put some kind of rodent on the cover? Not, I don't know... a python?
Maybe if the rat was being eaten by a snake it would make sense...
JavaScript is the language of the day today. (Score:1, Insightful)
Sadly, JavaScript seems to have become the fad language lately.
A lot of people who can only handle front-end web development thought Ruby would let them do something a bit more serious, so it had a pretty large hype wave while they were trying it out. But they've found even it too difficult, so they've abandoned server-side work in favor of client-side coding again. Unfortunately, this has to be done in JavaScript, since that's basically the only language supported by all major browsers.
It's a shame that we don't have Lua or Python in the browser instead of JavaScript. It'd make web development much more efficient. JavaScript is such a hack, and such a pathetic excuse for even a scripting language.
Better Than First Edition? (Score:5, Insightful)
I sincerely hope that this version is better than the first edition, although anything short of a random re-arrangement of pages would serve as an improvement. The first edition actually delayed my initial use of Python by about a year and a half. I had heard wonderful things about the language so I figured, "Ah, an O'Reilly book!" Big mistake.
Endless bits about immutability, without hints as to why I ought to care. I can appreciate the use of the interactive prompt now, but to start with it seems ... strange. I was not transitioning to Python from shell programming, and I doubt many do. Lambda expressions, entirely too early. Not a great deal of attention paid to idiom, which is just about central to learning a new language. Little discussion of how you might have accomplished tasks in other languages and wish to do the Pythonic equivalent. I loathed the first edition and refer to it precisely never. I eventually dropped it in a puddle and felt no urgency towards retrieving it. The now-wrinkly cover suggests that some unhappy deity has attempted to purify it by flood.
I ought to have tried fire.
Re:Monty (Score:3, Insightful)
Re:Monty (Score:3, Insightful)
What does the sheep on 'Perl Cookbook' have to do with anything?
Maybe mutton for dinner?!?
Re:Better Than First Edition? (Score:4, Insightful)
If not this book, care to share an alternative recommendation or two?
Well, I can't disagree with the grandparent's very nice flame, but why not start with Guido's tutorial? http://docs.python.org/tutorial/ [python.org] Between that and the library reference, I was up and running making useful scripts in an afternoon at work one day, but I had previous programming experience. But since this book isn't for people like that, who is it for? Only people I can think of are language lawyers, and there's a free source for that as well! http://docs.python.org/reference/index.html [python.org]
Re:Too wordy (Score:3, Insightful)
It's kind of surprising that Learning python is only 1000 pages, which is not too say that it isn't too wordy.