Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By : Dan Nixon
Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By: Dan Nixon

Overview of this book

Table of Contents (18 chapters)
Getting Started with Python and Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The Raspberry Pi is one of the smallest and most affordable single board computers that has taken over the world of hobby electronics and programming, and the Python programming language makes this the perfect platform to start coding with.

Getting Started with Python and Raspberry Pi will guide you through the process of designing, implementing, and debugging your own Python applications to run on the Raspberry Pi and will help you interact with some of its unique hardware.

What this book covers

Chapter 1, Your First Steps with Python on the Pi, introduces the Python development tools as you install and set them up on the Raspberry Pi after installing the Raspbian operating system.

Chapter 2, Understanding Control Flow and Data Types, introduces you to the control flow and conditional execution operations. Also, the basic data types and the operations that can be performed on them will be covered in this chapter.

Chapter 3, Working with Data Structures and I/O, gives you an overview of the standard Python data structures (for example, list, dict, and tuple) and how they can be used within an application. Also, this chapter will provide an introduction to reading and writing files on the Raspberry Pi's filesystem, including reading from the sysfs to get data such as the current temperature of the processor.

Chapter 4, Understanding Object-oriented Programming and Threading, introduces the concept of object-oriented programming and compares it to the functional programming that has been done up to this point in this book.

Chapter 5, Packaging Code with setuptools, introduces you to the setup tools in the Python package, which are used to package Python applications and libraries for easier installation. This will also include an introduction to the pip utility and PyPi package repository.

Chapter 6, Accessing the GPIO Pins, gives you an overview of the Python library for accessing the GPIO pins on the Raspberry Pi and a brief introduction to some basic electronics needed for the tutorials in the chapter.

Chapter 7, Using the Camera Module, covers using the picamera Python library to interact with the camera module, the options that can be configured using the library, and writing a simple application to record a section of video in several different modes.

Chapter 8, Extracting Data from the Internet, covers the use of several libraries (including requests and urllib2) to connect to webservers and request data, and will include obtaining weather forecasts from an online API. Also, you will be introduced to several third-party libraries that access data from specific sources.

Chapter 9, Creating Command-line Interfaces, covers interaction with applications via the command line using the argparse Python module.

Chapter 10, Debugging Applications with PDB and Log Files, introduces you to the PDB (Python debugger) tool, discusses how it can be used to diagnose and fix issues in Python programs, and covers how the logging Python module can be used to capture information from an application to be used later for debugging. This includes a tutorial in which code with several issues placed into it will be debugged and corrected.

Chapter 11, Designing Your GUI with Qt, provides an introduction to GUI design with Qt using Qt Designer and the Python Qt package.

What you need for this book

You will need:

  • A Raspberry Pi

  • An SD card (4 GB or higher)

Who this book is for

This book is designed for those who are unfamiliar with the art of Python development and want to get to know their way around the language and the many additional libraries that allow you to get a full application up and running in no time.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

flan = "495"
flan
type(flan)
flan_i = int(flan)
flan_i
type(flan_i)

Any command-line input or output is written as follows:

sudo python setup.py install

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Next we will disable the LineEdit widget that will be used for displaying the result of a unit conversion, this is done by selecting the widget and removing the tick in the enabled property in the Property Editor as shown in the following screenshot."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.