Review: Python for Secret Agents

If you’re looking for a fun, quick read that will show you some neat tricks for mashing up and manipulating data in Python, this is the right book for you. Python for Secret Agents has a wide variety of fun tricks. It’s got nice code examples that help you get to know many Pythonic best practices, and although it doesn’t descend below the language’s surface, it does give you glimpses of several builtin or freely available packages for solving problems across the board.

The book is clearly intended for beginners, and it’s written so that it won’t lose you if you read it. However, in keeping with the Pythonic philosophy, it tends to implement things only if they’re needed or if implementing them allows the author to show something useful to his audience. This has the positive effect that readers above the intermediate level can enjoy the book because they’re introduced to libraries that they might not have worked with before.

That’s not because the author works with exotic packages, but rather because he covers such a broad range of topics. I especially appreciated how the author always connected disparate sections that could have been written on their own. As it is, stringing them together brought them a lot closer to real-life projects.

For example, the author shows some simple text parsing tricks, followed by file compression and decompression. He then strings the whole thing together in a dictionary-based, very basic brute force password cracker that can decrypt a poorly encrypted zip file. Along the way, the author gently pounds the best practice into your head of always working with context managers when you have resources that need to be closed again.

This knowledge of context managers is brought into the next chapter, where you use them while downloading data from the Internet. The reader is then shown how to encode REST queries and parse XML in order to pull information straight out of different sources in the Internet. A short excursion into Python collection types helps the user to be ready to serialize and deserialize the data they find.

This knowledge is then applied again in a nice demonstration of some simple steganography, followed by a more complex mash-up of the content from the previous chapters, where the user serializes and deserializes geographic coordinates and uses them to look up objects with a REST API. The author shows an example of how to efficiently process the acquired objects using generators, connecting disparate data sources into a meaningful application tailored to the project’s needs.

The book was a lot of fun to read, and although it is not challenging, it provides a broad focus without sacrificing clarity or clearness. Beginners that start here will have the luck of being indoctrinated with generator expressions, context managers, simple unit tests, docstrings and exception handling, and they’ll learn the simplest beginnings of object orientation too.

I can thoroughly recommend the book to any beginner wanting to look into Python, and it’s worth thumbing through the table of contents if you’re past that level just to see if there are any examples that might be of interest to you. I’ll probably never pick it up again, but it was a fun read with some nice tricks I’ll be sure to remember.


My name’s Daniel Lee. I’m an enthusiast for open source and sharing. I grew up in the United States and did my doctorate in Germany. I've founded a company for planning solar power. I've worked on analog space suit interfaces, drones and a bunch of other things in my free time. I'm also involved in standards work for meteorological data. I worked for a while German Weather Service on improving forecasts for weather and renewable power production. I later led the team for data ingest there before I started my current job, engineering software and data formats at EUMETSAT.

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

From the archive
%d bloggers like this: