When I was first asked to write Hello! Python, I didn’t want to write just another introductory book—I wanted to write something different. The programming books that I’ve read in the past have often been just a laundry list of features: a list can have things in it, and you can call len(mylist) to find out exactly how many things, .pop() to chop an element from the end, .append() to add … There you go, that’s all you need to know about lists, now on to the next feature. If you’re shown a program, it’s usually either a trivial few lines or a couple of chapters tacked on to the end of the book as an afterthought.

Then I thought back to how I first learned to program. I didn’t read an entire programming book from cover to cover and then write a program after I knew everything there was to know. Instead I started with a goal, something that I wanted to do, and worked toward it, figuring things out as I went. I read programming books from time to time, but really only to figure out the bits I was stuck on. When I was done, my programs weren’t particularly elegant or fast, but they were mine—I knew how they worked, and they solved a real problem that I was having.

Fast-forward to today, and my programs are elegant and fast, for the most part. And most of the really good programmers I know have learned to program the same way. In Hello! Python, I’ve tried to re-create that process, but speeded up, with all the things I’ve learned about programming and the pitfalls I’ve encountered. Every chapter (except the first and last) includes a practical program at its core to illustrate either a particular Python feature or a library—often several. Some of them are fun, some of them are useful, but there are no boring beginning chapters where you learn, in excruciating detail, every feature of a list or dictionary—or, worse, learn how Python adds numbers together.

Instead, you’ll watch a program being written and learn about Python features as you need them, not before. Several of the chapters build on previous ones, so you’ll learn how to extend existing programs to add new features and keep their design under control—essential if you’re going to be writing programs of any scope. The book also explores several different styles of program, from simple scripts, to object-oriented programs, to event-based games.

The idea is to provide a book that’s different—that lets you begin writing programs from the first chapter and learn how to use Python’s features by seeing them used in action. I hope this is the sort of book that will help people really understand how to use Python.