Sunday, November 01, 2009

Learning Python 4th Edition (book review)

book cover of Learning Python

Learning Python, Fourth Edition
by Mark Lutz
O'Reilly Media, 2009
Paperback, 1,160 pages: $ 54.99
Ebook (PDF, MOBI, EPUB): $ 39.99
Visit the book's web page.

NaNoWriMoNational Novel Writing Month — begins today, November 1, and runs for 30 days until November 30. The goal of this project is daunting: everyone who participates must write a novel in a month. The novel is defined, ala E.M. Forster, as a prose work comprising a minimum of 50,000 words.

I do not participate — like Nelson Algren, I believe that a genuine novel takes a skilled author one year or two years to write. Nevertheless, I am a strong supporter of this project. The NaNoWriMo project promotes writing and reading, and improves one's skills in both.

Months ago, I had a spectacular idea related to novel writing and computer programming. Suppose there was an open-source software program that would help the writer in three phases of the work.

1. Planning the novel.

Abraham Lincoln said: "If I had six hours to chop wood, I would spend the first five hours sharpening my axe." If I were NanoWriting I would spend the first five days planning the book, and the remaining 25 days writing 2,000 words per day. My software program would provide simple yet flexible frameworks for planning many types of novels.

2. Copy Editing the novel.

Why isnt' there a push-button editing solution, that would work similar to a spell checker, and cover all the essential aspects of copy editing?
photo of Maxwell Perkins

3. Content Editing the novel.

After November's 30 days expire, you might have a reasonably acceptable first draft. The fledgling novel would now be processed by my software program, for what is known as "content editing" or "substantive editing", revising the work — its structure, characters, plot, dialogue, and themes — to raise its quality.

I named my program MacPerkins, after the extraordinary American editor, Maxwell Perkins, who nurtured many young writers to greatness.

What I needed now was some solid advice from professional programmers, about which programming languages might be used to make MacPerkins work. There is no shortage of programmers in this little town, and soon I had myself invited to a gathering, where "a hackle of programmers" — to coin a collective noun like a gaggle of geese, a flutter of butterflies, a crash of rhinoceroses, and a murder of crows — a hackle of programmers had gathered to discuss their favorite things.

After describing my project in great detail, I asked which language might be used.
Charlie replied: "Python."
Greg declared: "Python."
Kathy hummed: "Python."
Ann said: "Python."

"And how," I asked, "can I learn the Python programming language quickly and efficiently?"

Again, the answers were unanimous. All four of my programming-expert friends suggested the same book: Learning Python by Mark Lutz.

And now about the book itself. On the back cover you'll see a line that displays the level of the book rated as "Introductory". And the author writes that no previous experience (with Python, or with programming) is needed to use this book. Furthermore, "... compared to other programming languages, the core Python language is remarkably easy to learn. In fact, you can expect to be coding significant Python programs in a matter of days (or perhaps just in hours, if you're already an experienced programmer)."

The book claims to be "Introductory", but by the time you complete its almost 1,200 pages, you will not be a beginner anymore.

The book is written for all the major platforms: Windows, Linux, Mac. The focus is on Python version 3.0 (which the author recommends), but there is ample material about version 2.6, for those Python users who need to work with that earlier version.

Quizzes are provided at the end of each chapter, and the quiz answers are smartly situated immediately after the questions. Exercises are given at the end of each section, with answers in the back of the book.

I found the book interesting reading, as well. There are comments about the great debate that compares the features of Python and the features of Perl. There's a lucid explanation about the difference between compiled languages (such as C and C++) and interpreted languages, such as Python. There is a list of common Python mistakes, and common beginner traps. And all the geeky jargon is well explained: I might have been intimidated by the term "modules", but not after the author tells us that "Modules are simply text files containing Python statements" — and I'm not afraid of modules anymore.

I was in the middle of page 100 when I realized that I was reading a book about computer programming: everything to that point seemed so straightforward and easy to grasp. I said to myself: "This is not a typical programming book: it is better."

When the author provides sample lines of code, in the next paragraph he explains the meaning and the purpose of each line. There are no sudden and perplexing pits of literary quicksand: new material that leaves you scratching your head, and re-reading again and again, to grasp a scintilla of clarity from the murky text.

Lutz developed this book in conjunction with a very popular course he teaches about Python. That real-world connection explains how he skillfully anticipates all the questions and problems that beginners might encounter.

Flashing back to the party with my programming friends — before I opened my copy of this book — I asked what I could do if I had questions about the new language. Once again, my friends agreed: they laughed together and said: "Good luck." (They were joking of course: they are all happy to help in any and every way.)

But no luck is necessary when you have an excellent teacher between two covers, such as Learning Python.

Thanks to this book, I am already writing simple Python programs. MacPerkins, and next year's NaNoWriMo — here I come.

— Michael Pastore

Story Links

Learning Python web page:

Python (programming language) in WikiPedia:

Python Official Website