Introduction
AFTER A CONFERENCE ONE YEAR,an e-mail went around the PyLadies organizers mailing list asking, Is anyone interested in writing a Python book? I had kicked around the idea of a programming book for a while. After teaching for a couple years and mentoring at PyLadies and other coding meetups, I realized there was a need for a new, specific sort of programming book. I didnt jump to replying to the e-mail, however. I knew that writing a book would be a big process (boy is it!) and that it would take a lot of time and effort on my part, in the way of working on the weekends and holidays (yep, check!). I also knew that I had a full-time job teaching programming, I was the lead organizer for my local PyLadies chapter in Atlanta, Georgia, and I had children that would soon start asking, Are you writing this weekend?
All of the above was true (a little more than I originally thought, actually), but I knew that the book was important. There were so many of my students asking me at the end of class, Now that I know the basics of Python, what do I do? My answer was always something along the lines of, You can get involved in open-source projects! or Take the advanced Python class! But none of those answers satisfied them or me. The answer is, You have to really start looking for something to work ona problem to solve, a need that must be met. Because, the only way to really know and understand programming and a programming language is to solve problems with said language.
But then the problem of But I dont have a problem that really needs to be solved cropped up. So while I could send my students off to look at open-source projects that do, in fact, need the help, if they didnt understand the technology, theyd be lost and give up. Then the community loses yet another programmer who may have brought interesting things to the table. So, thats when, after lots of talking to friends and family, I realized that this book needed to be written.
Why We Wrote This Book
For all those people who came up to us and asked, over the years, What can I do now that I understand Python basics? What things can I learn? Where do I go? Thats why we wrote this book.
The most chronic problem in programming books that weve experienced and that others have also felt they experienced is that it goes from These are the basics of a language into very deep concepts that only people who hold Computer Science (CS) degrees would understand. And thats not cool. Programming should be open to anyone who is interested. We should all be working toward making the bar into programming a little lower. We feel that Python accomplishes this, but we need to take it a step further and begin to understand how people learn abstract ideas and concepts, to help us help them learn.
Think of programming like learning how to build a house, but only understanding that wood is needed and how the wood works to build a house. You still need to understand structural engineering, electrical, plumbing, ventilation, HVAC, etc. The same concept is true for programming. Languages just explain the wood being used in a house. There is plenty more that is happening in harmony with the wood, and we want to help you uncover those concepts.
Who This Book For
This book is not for beginners who want to learn Python. Rather, as a reader of this book, you need to already have some Python programming under your belt. That means youve done some tutorials. You also understand that whitespace matters in Python and that lists are denoted with hard braces ([ ]
) while dicts (dictionaries) are denoted with curly braces ( { }
). This book is for those people who are still beginners, but who have completed a tutorial or twofolks who understand the basics of Python, but are interested to learn what all they can do with Python.
Need is the mother of invention goes the saying, and when youre learning to program, this is very true. If you need a piece of software that can perform a specific function or task, its easy to learn a language around that need. You have a need, the language will help you, you learn the language, you solve the problem, youve learned a thing, and youve put it to use immediately. This is awesome and fantastic! However, what if you think programming is interesting, but youre missing the need? What if you dont know what to make? Thats where this book comes in.
This book will help you to learn the parts of Python that most people dont think to tell new programmers about. Most of the things covered in this book are tools and technologies that one may only discover when they are faced with working with them. However, for new programmers who dont have a specific problem to solve, learning these tools can be difficult. Most of the time no one thinks to introduce these topics to programmers because they are used so regularly. We hope to take you on a journey through the power of Python and all of its splendor.
You will learn how to make a web app, how to talk to a database using Python libraries, and which system tools can help speed up your workflow, if youre a systems administrator. We will briefly touch on topics such as security and best practices. Youll get an overview of creating graphical user interfaces (GUIs) using Python libraries. We will cover consuming and producing application programming interfaces (APIs) and many other topics that are beneficial to Python programmers.
What You Will Learn
We hope to take you on a small tour of the basics that are available in the Python ecosystem. Well introduce you to many concepts that are usually discovered only while working on a problem to solve. While we cant put everything into the context of problems that you may need to solve in the future, we hope that we can illustrate the powerful features of the Python language and the available packages and technology that are available to you, the new Python programmer.
We will start out with a brief crash course in Python, in case youve forgotten anything. Well go over the basics, and then you can decide if you want to read that chapter in its entirety or not. Next, we go over Python as a scripting language. Youll get to get your hands dirty, as it were, by writing small scripts to access parts of your system, using Python. This should illustrate the very basic power you have with the language. Third, well start talking about data, which is what programming is all aboutmanipulating data. Youll get to dive in and work through some examples using some of the standard libraries that come out of the box with Python. Well even discuss databases so that you can get a quick intro into those. We want you to see and touch every part of a system that you may come in contact with.
After the first three chapters, youll dive into desktop applications. While these arent incredibly popular in Python, it is a feature of the language, and it could be useful down the line in your tenure as a Python programmer. Next, we will step out of the desktop and onto the Internet with Python as a data communicator. Youll learn all about HTTP and the Web and how websites work under the hood. Youll even be able to play with producing and consuming APIs. APIs confuse many new programmers; we hope to have removed much of the mystery with this chapter.
In the final chapters, well show more advanced topics in Python, such as how to work with Python in bigger projects, debugging your code, creating testing-harnesses, handling errors, and even creating your own exceptions and exception handlers! Finally, there are appendices for reference while you are going through the book and after, when youre spreading your Python wings and programming.
Next page