Sign up for updates!

Hi! 👋 Please sign up to get notified when I release the source code for this book on GitHub. Till then, I would greatly appreciate if you can submit all the grammatical, prose and code related issues here.

I post about once every couple of months. No spam, I promise

1 Introduction

Hi everyone! What you are reading right now is the culmination of more than two year’s worth of hard work. I started working on this book at the beginning of 2018, kept working on it whenever I found a new project idea and spent the longest time proofreading it. The motivation behind this book is pretty simple; when I was learning to program, most books, websites, and tutorials focused on teaching the intricacies of the language. They did not teach me how to create and implement end-to-end projects and this left a void in my understanding. I knew of different libraries and frameworks and how to use them on their own but I did not know how to combine them to make something unique.

All that frustration led me to write this book. I am assuming that you know Python and are fairly comfortable with it. I will be taking you through the development of various end-to-end projects. Some of these projects are web apps and this means that you will need to know the basics of HTML and CSS as well. If you don’t already know the basics of HTML and CSS, you should take a short course on Codecademy or a similar website. We will not be making extensive use of stuff other than Python but you need to know enough so that you can follow along. As far as Python knowledge is concerned, if you have completed an intro to Python book you should be good to go.

If at any point you feel like you would benefit from some more Python practice, I would recommend reading Automate The Boring Stuff With Python. You don’t need to read it cover-to-cover, just the early chapters should be enough.

In each chapter, I will try to teach you a new technology through the development of a new project. Some of the projects might appear to be repetitive but rest assured, each chapter contains new information.

1.1 Who should read this book

It is really hard for me to strictly define the audience of this book because there is something for everyone in it. If you just finished a basic Python book then this book will teach you how to mix different libraries and make something unique. For people with more experience, this book will show you some creative projects (and their implementation) so that you can brainstorm more ideas to keep you busy on a free weekend.

If you are a beginner and find yourself getting lost at any point in the book it might be because some projects make use of stuff that doesn’t necessarily fall under the Python umbrella. There might be points where you will need to do a quick Google search. I promise you that if you stick with it, you will come out as a more knowledgeable (if not better) programmer.

1.2 How to read the book

I have tried to arrange the chapters in a loose hierarchical structure so I would suggest reading them in the order they are listed. For example, we use Flask in multiple chapters. In the first chapter, I go into the details of how Flask works but in later chapters, I gloss over the basics. If you are a beginner it is in your best interest to read them sequentially.

However, other than that, each chapter is more or less independent. This means that you can start with whichever chapter seems most interesting. For more experienced people skipping chapters should not cause any problem.

1.3 Conventions

In this book, all terminal commands will be prefixed with a $ sign and all Python code will start directly with the actual code. I use an inline-code block for anything which is code related. This includes variable names, method names, and the libraries used.

I am hopeful that nothing will confuse you because I specify if the upcoming text is Python code or something that needs to be typed in the terminal. Additionally, the book comes with accompanying code files for each chapter so that you can see the final code I wrote for a specific project.

I will be departing from PEP-8 wherever necessary for code presentation purposes. I have deliberately tried to split long code into multiple lines using \ (StackOverflow). However, in places where I have forgotten to do that the code will overflow to the next line and will be prefixed with a curly arrow. Please pay attention to those.

I will not cover productionizing a web-app in each chapter that deals with web-servers, instead, I will cover the general cases in a dedicated chapter so that I can reduce text duplication. There is a chapter at the end of the book which deals with productionizing Flask projects using Docker. Give it a read once you finish up a Flask based tutorial.

Most importantly, I will use Python 3 throughout the book-more specifically, Python 3.8. However, any Python version greater than 3 should work fine for all the projects.

I will be making extensive use of touch, cat, and echo at the beginning of each chapter. If you don’t know what they are or how they are used, I would suggest you do a quick Google search and learn before starting any chapter. It shouldn’t take more than 10 minutes to learn the basics. cat and touch might show up in code listings. Make sure that you don’t put them in the actual code files. If it sounds confusing, don’t worry. It will all make sense once you see the code listings.

Windows users can substitute touch, cat, and echo according to the table:

Original

Windows

touch

echo >>

cat

type

echo

No easy equivalent

You will also frequently see # ... in code listings. This is a placeholder that is there just to tell you that some additional code is supposed to go there. This helps me complete projects step by step and show you the general code structure before filling in the details.

I would also like to mention that in this book I have decided to not focus on writing tests. A lot of people familiar with my work will consider that a huge step back for me, yet the majority of the projects in this book are so small that the lack of tests shouldn’t be a big problem. Moreover, for some projects, I am just not sure what the best way of testing them is. I don’t want to teach you bad testing strategies, and the book is still in beta, so I might go back and add tests at a later stage. For now, they are not on the roadmap.

You will also encounter some admonition boxes throughout the book. These are of three kinds:

Warning

This is a warning. You should pay close attention to what this says otherwise the world is doomed.

Note

This is a note. It is useful to look at but if you don’t look at it, the world won’t end.

Attention

This contains information that is close to a warning but can be skipped if you want.

To be fair, I use such few admonition boxes throughout the book that I would highly recommend you pay attention to all of them.

1.4 Code files

All the projects have an accompanying folder in the online repo. The complete code for the projects is stored there. Just install the required libraries listed in requirements.txt files in the project folders and you should be able to run most projects. The repository also contains all the code listings from the book. This is particularly useful if you are reading the book on Kindle and would like to see the code in a nicer format on your laptop/PC.

1.5 Feedback

If you find any mistakes or errors in code samples or text, please reach out to me at hi@yasoob.me and I will make sure that the errors are fixed as soon as possible and you get credit for it. We have also set up a GitHub repository where you can submit issues. I also love getting suggestions so please reach out to me with new ideas (or even if you just want to say hi!). I try my best to respond to all the emails I receive.

Finally, thank you so much for deciding to read this book. You and all the other readers are the reason I wrote this book so I hope you learn something new and exciting from it. See you in the first chapter!