A Primer on Scientific Programming with Python simultaneously introduces us to the Python programming language and its use in scientific computing. The emphasis from the beginning is on practical computation. The first chapter the book introduces the
numpy numerical library and the IPython shell, topics often mentioned at the end of other books, if they are mentioned at all. Including these tools early on is appropriate given the book’s purpose. For someone primarily interested in scientific computing, these tools are more fundamental than some of the less common features of the Python language.
Langtangen’s Primer is truly a textbook, not just a technical monograph that the publisher says could be used as a textbook. In some ways it feels more like a college psychology textbook than a typical programming book. It is a hardback book with slightly glossy paper and baby blue highlighting around code samples. It has frequent headings, exercises, etc. In short, it goes to great effort to be easy to study. On the other hand, some more experienced programmers may prefer a faster-paced book.
The Primer focuses on scientific programming but not numerical analysis per se. The emphasis is on the implementation and use of numerical algorithms rather than their theoretical derivations.
The reader will learn good Python programming style from the Primer. The book will often present a direct solution using only the most basic language features and follow it by a more elegant, more idiomatic solution.
One of the strengths of this book is that it includes material that is not often described in books. Those who use Python for scientific programming eventually discover libraries such as
scitools, though these are not often covered in books on Python. In addition to purely mathematical computation, the book covers peripheral tasks that are often necessary such as automating grabbing web pages, parsing CSV files, and processing command line arguments.
Those of us who have learned scientific programming in Python “on the streets” could be a little jealous of students who have the opportunity to take a course out of Lantangen’s Primer.
John D. Cook is a research statistician at M. D. Anderson Cancer Center and blogs daily at The Endeavour.