Archive for February, 2014

I had a lot of ideas for the cover of Python 101. My first idea was to go to the zoo and take some photographs of Pythons there, then pick the right one stick that on the cover. I have a lot of photo editing software, so I also considered taking the photo and changing it so it looked like a drawing or a painting. Then I started thinking about my blog and how my readers were the ones encouraging me to write the book in the first place. So I ended up going with one of my other ideas, which was to continue the Mouse Vs Python theme.

I ended up hiring an artist I know who did my original blog logos. His name is Tyler and he owns and operates Killustration Studios. You can see some of his work on deviantArt. Anyway, I told him my ideas for the book cover and I thought I would share the various versions of the cover as it evolved.

The First Rough Cover

The following image is the first version of the cover. It’s pretty rough, but I could see my vision taking shape:



Python has a vast library of modules that are included with its distribution. The csv module gives the Python programmer the ability to parse CSV (Comma Separated Values) files. A CSV file is a human readable text file where each line has a number of fields, separated by commas or some other delimiter. You can think of each line as a row and each field as a column. The CSV format has no standard, but they are similar enough that the csv module will be able to read the vast majority of CSV files. You can also write CSV files using the csv module. (more…)

Python has a number of different concurrency constructs such as threading, queues and multiprocessing. The threading module used to be the primary way of accomplishing concurrency. A few years ago, the multiprocessing module was added to the Python suite of standard libraries. This article will be focused on the threading module though. (more…)

I’m sure some of you have been wondering if I had a more concrete outline of the book that I am currently writing. As a matter of fact, I do. Here’s what I have so far:

Part One: Learning the Basics

  • Chapter 1 – IDLE
  • Chapter 2 – Strings
  • Chapter 3 – Lists, Tuples and Dictionaries
  • Chapter 4 – if/elif/else statements
  • Chapter 5 – Loops
  • Chapter 6 – Comprehensions
  • Chapter 7 – Exception handling
  • Chapter 8 – Working with Files
  • Chapter 9 – Importing
  • Chapter 10 – Functions
  • Chapter 11 – Classes

Note: Part One is written and in the editing phase



My readers have been asking me to write a book for a few years now and I’ve finally decided to bite the bullet and give it a go. For my first book, I decided to write something that’s for beginners and intermediate programmers. There will be four parts to the book with the first part being aimed squarely at the beginner programmer. The next 3 parts will follow a more cookbook-like style in that they will contain a lot of tutorials. I’ll be folding some of the articles from my blog into the book and updating them if appropriate, but there will be plenty of new content.

To get things going, I am running a Kickstarter campaign. to raise some funds to help in the development of the book. If you’ve ever found this blog useful, please consider supporting the funding of my book.

I copied most of the text from the Kickstarter campaign here for your convenience: (more…)

Last year, Packt Publishing asked me to be a technical reviewer for a book called Python High Performance Programming by Gabriele Lanaro. It was published in December, 2013. For those of you with short attention spans, I give you my short review:

Quick Review

  • Why I picked it up: I got it for free, but I would have picked it up because the subject matter interested me
  • Why I finished it: This book had lots of interesting tips that made me want to keep reading it
  • I’d give it to: Someone who wants to learn about optimizing their code

If that whetted your appetite (more…)

I work with a lot of dictionaries at my job. Sometimes the dictionaries get really complicated with lots of nested data structures embedded within them. Recently I got a little tired of trying to remember all the keys in my dictionaries so I decided to change one of my dictionaries into a class so I could access the keys as instance variables / attributes. If you’ve ever gotten sick

Here’s one simple way to do it:

class Dict2Obj(object):
    Turns a dictionary into a class
    def __init__(self, dictionary):
        for key in dictionary:
            setattr(self, key, dictionary[key])
if __name__ == "__main__":
    ball_dict = {"color":"blue",
                 "size":"8 inches",
    ball = Dict2Obj(ball_dict)


The people at Packt Publishing recently sent me an ebook copy of Raúl Garreta and Guillermo Moncecchi’s book, Learning scikit-learn: Machine Learning in Python to review. Machine learning isn’t a topic I’m very familiar with, but I gave the book a shot as it sounded interesting. I’ll start off with my quick review for those of you with little time:

Quick Review

  • Why I picked it up: This book was a review copy, but I’m actually interested in just about any Python programming book
  • Why I finished it: The book is well written and while I don’t understand a lot of it, the gist of the text was interesting…and I skimmed a lot.
  • I’d give it to: Someone who uses Python for scientific purposes or machine learning

If you found that intriguing, then feel free to read the full review! (more…)

Python’s logging module has lots of options. In this article, we will looks at the logging module’s ability to create Rotating Logs. Python supports two types of rotating logs:

  • Rotate logs based on size (RotatingFileHandler)
  • Rotate the logs based on some time interval (TimedRotatingFileHandler)

Let’s spend some time learning how each of these two types of loggers are implemented and used. (more…)

What’s the most popular language of 2013? According to, it’s Python! If you compare that with TIOBE, Python is only at #8, but at least it’s still in the top ten! Hopefully Python will continue to gain in the ranks and be used in many new places in 2014.

You might also find the newer PYPL PopularitY of Programming Language Index helpful too, where Python places 3rd as the most searched for programming language for tutorials.