Getting Started with Python and Raspberry Pi – book review

David Whale sent me a couple of books to look at recently. The first, Getting Started with Raspberry Pi Zero, I reviewed a few weeks ago. I now come onto the second one: Getting Started with Python and Raspberry Pi by Dan Nixon.

I feel I have to start by giving an indication of whom I believe the book is aimed at. It is in my opinion, surprisingly, not suitable for beginners. Even though it has the ‘Getting Started’ title, it is very much suited to people who are programmers already, rather than absolute beginners. The structure of the book, and some of the concepts covered, is more at an intermediate or advanced level – suitable for those comfortable with programming concepts, but unfamiliar with the way Python “does it”. With that in mind, I did start to wonder, halfway through, as to whether the ‘Getting Started’ moniker actually did the book a disservice.

The book starts off optimistically enough with a chapter on installing Raspbian and configuring it. Now, the book was published in September last year and Raspbian has since come on a long way, particularly in the area of wifi configuration, so there are a number of things in the chapter that don’t apply any more. This isn’t the fault of the author, of course: Raspbian is a bit of a moveable feast when it comes to interfaces and features. However, it does make me wonder: Are we now past the point where an installation and configuration chapter is advisable or even needed? This chapter also explains that we are going to be using Python 2.7 rather than Python 3. This was a bit disappointing as version 3 is clearly the way forward, but I can understand the argument that there are more libraries available for 2.7. I would think, though, that even if you are using Python 2.7, you would use, for example, the print(” “) syntax rather than the print ” ” syntax, just so that when you move to Python 3 it ‘just works’. Unfortunately, the old way of doing certain things, regardless of any upwards compatibility, is very much adhered to in this book.

The next chapter concerns control flows and data types. This is when I realised that the book must be aimed at existing programmers. Rather than teaching by example, which is the way most beginners books go nowadays, this book instead goes for a bottom-up approach. It does mean that absolute beginners will flounder at this early stage. Indeed, they may be asking “What the heck is a ‘control flow’?” Again, it’s not the content of the book that is in question – in fact, it’s very well-written and the content is terrific for existing programmers – it’s just that the title of the book doesn’t help very much to indicate who it is aimed at.

The next couple of chapters go into data structures, I/O, object-oriented programming and threading. These are very advanced topics, particular OO and threading, and I was surprised to find them in a Getting Started book. They are very welcome from my point of view – being able to do more than one thing at once is key to modern programming – but still… The book hasn’t really taught very much before getting to this point, and I wonder if a regular reader is ready for such advanced concepts.

The next chapter, likewise, seems very advanced for a Getting Started book – it’s all about packaging up your code. Very useful, but perhaps it should have been included at the end so that when you’ve created something substantial then you can learn how to package it.

Next up is a chapter on using the GPIO pins of the Raspberry Pi via the RPi.GPIO library. With the advent of GPIO Zero, this seems to be a little ‘old-hat’ but of course with a September 2015 publication date, the new library wasn’t really around to be used. What is in the chapter, however, is excellent as it deals with using LEDs, switches and also PWM. I do note that the author is still using ‘sudo’ to execute the Python commands. This won’t do you any harm, of course, but it is now not necessary.

The camera module is the subject of the next chapter and I’m pleased that the author chose to go along the picamera library route as it is an excellent library. He goes very quickly through basic use and then goes into using threading with the camera. This surprised me as I would have thought a Getting Started guide would go more into the functionality of the picamera library. As it is, the more advanced features of the library are glossed over or, in a lot of cases, skipped entirely. This may be because the author wished to get back into strict Python quickly, but it is a missed opportunity in my opinion.

The next chapter is extremely interesting and well thought-out. It deals with consuming APIs over the Internet in a variety of data formats such as XML, JSON and even how to parse HTML using BeautifulSoup. A great chapter, but, perhaps, a list of more APIs that can be accessed would have been welcome.

Creating command-line interfaces is to do with creating ‘executable’ programs using Python. Interesting, but again slightly beyond the remit of a Getting Started guide.

Debugging using PDB and log files is tackled next. Very useful for more advanced programming when you need a lot more tracing. I’m just not sure that the book has got the reader far enough along to merit introducing the topic.

Finally, there is a good chapter devoted to designing GUIs with Qt. This is very interesting and useful and covers using Qt Designer to design forms and screens as well as interacting with them at code level. The form designer reminds me of Visual Basic and even Microsoft Access! This chapter is of particular use to those who want to be able to program for the desktop environment.

Summing up

This book is very well-written. It teaches people who are already familiar with programming how to do things the Pythonic way, covering the details of Python code structure and taking a broader approach to other topics. However, despite this I feel that the title of the book is misleading. “Getting Started” clearly points toward the book being suitable for beginners. Beginners, however, would be lost by chapter 2. I think the best way I can say it is that the book is great if you are used to a from-the-ground-up approach. However, if you’re looking for a book with lots of worked examples that take you through programming in a logical, friendly way, then this one is probably not for you.

I commend the author and editors for trying to cover a lot of ground with the book. However, based on the title, it is not quite what I was expecting!

7 comments for “Getting Started with Python and Raspberry Pi – book review

  1. You have said what i said over a year ago we dont need how to set up pi that should be a book to itself. It seems that everybook including one i got on raspberry pi security penetration where its aimed at the advance user but spends a couple of chapters telling you how to burn the image to sd and how to set the pi up. Later in the book tells me i would need another book to learn something else of which has a few chapters in first setting up the pi. my only conclussion is they do this to make the book look bigger than it actually is.

  2. Nice review. “Getting Starting” might be a misnomer, but I would like to think there’s a market for books on intermediate and advance topics.

    I know Dan from Newcastle’s Maker Space and he’s a very active maker so I would guess a lot of his writing comes from this experience.

    I liked Dan’s previous book, “Raspberry Pi Blueprints” which is more project based. I get a nice shout out in chapter 3, Gaming, for my Pi based arcade project (R-Kade).

    • Absolutely, I think there is definite interest in the intermediate/advanced area. I just wish that this book had it’s title aimed at that market – I think it would sell better.

  3. I Think there would be an interest in ” The Raspberry PI Standard Library which would include all Raspberry Pi API’s Camera (for example) and GPIO.ZERO. Include all API’s not in the Standard Library. (And a link to the Standard Library Docs) “Getting started with the PI Library”

    This might be best as a Attribution copyright on a website and a real copyright through a book publisher like for instance Zeb Shaw did on LPTHW.

    • I think a book or at least some kind of online publication that looked at GPIO Zero and the Camera library would do very well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.