Jump to ratings and reviews
Rate this book

Python for Secret Agents

Rate this book
If you are a Python beginner who is looking to learn the language through interesting projects, this book is for you. A basic knowledge of programming and statistics is beneficial to get the most out of the book.

216 pages, Kindle Edition

First published January 1, 2014

4 people are currently reading
44 people want to read

About the author

Steven F. Lott

18 books6 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
3 (20%)
4 stars
6 (40%)
3 stars
3 (20%)
2 stars
3 (20%)
1 star
0 (0%)
Displaying 1 - 5 of 5 reviews
15 reviews3 followers
October 2, 2014
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.
Profile Image for Arthur.
97 reviews5 followers
October 10, 2014
This book is about learning Python, but in such a way you will be hardly able to put the book aside. So do not be fooled by the title. Yes, you will learn about modules, classes and even unit tests!And event hough Python for Secret Agents is seemingly aimed at beginner programmers it shouldbe pure fun for the rest of us. In my view this book constitutes serious work covering such important and frequently used techniques as accessing remote data, getting files over FTP, RESTAPIs, JSON(including serialization), ZIParchives, Geospatial calculations or simply teaching such common techniques as file path processing, numerical computations, lists and dictionaries or Unit Testing. And clever statistical data processing, too. NumPy,SciPy libraries are covered which is a great plus.

I was able to extract a ton of useful approaches to dealing with web data – BeatifulSoup is among the ones. The book became more and more exiting as I progressed through it until that all unfolded into one aha moment and finally exploded in a-la Cirque De Soleil kind of finale - last chapter: “A Spymaster’s More SensitiveAnalyses”.

A great, great rare read I did not experience for a long time. Thank you Steven F. Lott! I am looking forward to reading more books from you.

For the sake of this review and by means to downgrade my mark if I had to mention a few deficiencies that would be the lack of sample output (I just not always had the time for running each code example), nor does it provide examples on how to work with shape data (geolocations), but the Shapes is old school.

So all in all it is worth your buck.

Five out of five!
1 review
October 15, 2014
Some times ago I received a copy of "Python for Secret Agents" by Steven F. Lott.
"If You want to learn Quick - Do it on real projects"
The book consists of several chapters: Chapter 1 - a brief overview of Python 3, Chapter 2 - Preparation of a variety of data from the Internet and it's processing, Chapter 3 - image processing, Chapter 4 - receiving GPS data and processing, Chapter 5 - a deeper analysis of the data.
For me, as a Python programmer with an average experience, the most interesting and useful was the sections: about working with HTTP and FTP protocols, as well as examples of work with various REST API (Chapter 2). These topics are usually treated surfaces in the more well-known books on Python 3; section devoted to image processing (Chapter 3) - it is difficult to find a book where the information would be presented together with a detailed description of the language. Usually it is necessary to look for a separate manual; and of course the section devoted to the preparation and processing of GPS data (Chapter 4).
In general, this book can be recommended as a good guide for beginners to learn Python 3, because it is not a dry exposition of the theory, it's an excellent textbook with real examples. Likewise, the book will be useful to programmers which already practicing in Python 3, but did not encounter with specific problems discussed in it.
Profile Image for Jared.
1 review1 follower
October 15, 2014
Disclosure: I was provided a copy of this text by Packt Publishing in order to write this review.

The title of this book intrigued me from the start, and I was not let down throughout its entirety. "Python for Secret Agents" will quickly walk you through using Python to overcome the kinds of obstacles encountered by an agent; such as decrypting a zip file, manipulating images, including steganography, and geocoding. You will also be introduced to several Python libraries including Pillow and Beautiful Soup.

I would recommend having at least some experience with Python or programming prior to working through this book; as this will enable you to get the most out of the text.

Overall, this was a very entertaining read that provides many fun examples of how to use Python to solve problems.

Publisher's website for the book: http://goo.gl/o3sPQf
Profile Image for Bernie.
10 reviews
December 6, 2014
I must admit it was the title that had me reaching for this one. I expected a tour of penetration tools with the mandatory Kali Linux reference somewhere.

Instead, I found that Mr Lott has taken a directed learning approach to teaching the fundamentals of data gathering (From FTP, REST, JSON, etc) and manipulation with Python.

He also goes through enough detail on such matters as exception handling, password recovery, file manipulation and elements of programming style to make this a valuable manual on the topic; even without the thematic examples.
Displaying 1 - 5 of 5 reviews

Can't find what you're looking for?

Get help and learn more about the design.