This week I’m joined by David Amos, the content technical lead here at Real Python.
In this interview, we talk about David’s love of LEGO and mathematics. We also talk about the Python Basics book, which is soon to be out of early access, and his involvement with PyCoder’s Weekly. So, without further ado, let’s get started.
Ricky: Thank you for joining me, David. Many of our readers and members may already know your background, but for those who don’t, let’s ask the inevitable questions: How did you get into programming, and when did you start using Python?
David: I discovered programming by accident when I came across the source code for the Gorillas game on my parents’ IBM 386 PS/2 computer. I guess I was about seven or eight years old. I found something called a
.BAS file that opened up a program called QBasic and had all sorts of strange-looking text in it. I was instantly intrigued!
There was a note at the top of the file that explained how to adjust the game speed. I changed the value and ran the game. The effect was instantly noticeable. It was a thrilling experience.
I was obsessed with learning to program in QBasic. I made my own text adventure games. I even made a few animations using simple geometric shapes. It was tons of fun!
QBasic was a fantastic language for an eight-year-old kid to learn. It was challenging enough to keep me interested but easy enough to get quick results, which is really important for a child.
In college, I decided to major in mathematics, but I needed a minor. I chose computer science because I thought having some experience with programming would make it easier to complete the degree requirements.
I learned about data structures with C++. I took an object-oriented programming class with Java. I studied operating systems and parallel computing with C. My programming horizons expanded vastly, and I found the whole subject pleasing both practically and intellectually.
At that time, I viewed programming as a tool to help me with mathematics research. In graduate school, I wrote programs to generate examples and test ideas for my research projects.
It was during graduate school, around 2013, that I found Python and pretty much instantly fell in love. I’d been using C++, MATLAB, and Mathematica as my primary research tools, but Python allowed me to focus on the research problem without getting caught up in the code.
And with Python’s awesome ecosystem of tools for scientific computing, like NumPy, SciPy, PuLP, and NetworkX, I had everything I needed to tackle problems like I would with MATLAB but in a much more expressive manner!
Ricky: You often hear the myth that a strong mathematics background is a prerequisite to be a programmer. While I think you’ll agree that it’s not always necessary for programmers to know advanced math, I’m curious to know how your math and data science background has helped you when writing code.
David: If you want to be a computer scientist, then you do need a strong mathematics background. Not all programmers are computer scientists, though, and not all computer scientists are programmers.
A programmer’s job is to write code, but I’ve never had a job as a programmer in which someone hands you a program written out in plain English and asks you to translate it into Python. So the programmer’s job isn’t translating a human language into a computer language.
Where mathematics, computer science, and programming all intersect is problem solving. That said, mathematicians, computer scientists, and programmers don’t solve the same kinds of problems.
Mathematicians solve problems about mathematical structures. Computer scientists, whom I view as applied mathematicians, solve mathematical problems concerning structures that arise from the study of computation.
On the other hand, programmers are more like builders and engineers. A programmer is typically given a design and tasked with implementing that design as efficiently and effectively as possible.
Despite these differences, there’s a universal framework for solving problems that works regardless of the discipline. I think this framework is most elegantly laid out in George Pólya’s classic treatise How to Solve It: A New Aspect of Mathematical Method.
The framework has four stages, accompanied by questions that you should ask yourself at each stage:
- Understand the problem: What is the unknown? What are the conditions?
- Devise a plan: What tools are at your disposal? Have you already solved a similar problem, and can that problem’s solution help you?
- Carry out the plan: Can you check that each part of the plan is correct?
- Look back: Can you prove that your solution works? Can you think of another way to solve the problem? Could you use this solution for another problem?
Pólya’s problem-solving method is incredibly powerful, and although the book is written for students of mathematics, there’s a lot that everyone can learn from reading it. All of the book’s examples rely on mathematics one would encounter in a typical middle school or high school curriculum in the United States.
The most powerful idea I learned as a mathematician—which applies equally to programming, and indeed to everyday life—is that few problems are unsolvable. Often the key to solving a problem is asking the right question about it. (Actually, there are lots of problems that can’t be solved, but you aren’t likely to encounter those problems as a programmer!)
If you can’t solve a problem at first glance, then come up with a related problem that you can solve. In fact, that’s a mantra repeated over and over in How to Solve It:
You do not despise little successes, on the contrary, you seek them: If you cannot solve the proposed problem try to solve some related problem.
— George Pólya
Ricky: You’ve had a significant hand in rewriting and modernizing the original Real Python Course and turning it into what is now the Python Basics book. Could you speak a little about the new book? Who would benefit from reading it, and what can the reader expect to learn as they complete the book?
David: Working with Dan Bader, Joanna Jablonski, and Jacob Schmitt on Python Basics: A Practical Introduction to Python 3 has been both challenging and rewarding.
Thanks to Fletcher Heisler, the author of the first Real Python Course, I had a strong foundation on which to build. I did rewrite large portions of the book with two primary goals in mind:
- Update the content for more recent versions of Python.
- Ensure the writing met or exceeded the same standards as other Real Python written content.
Fletcher’s book is fantastic, but the style is substantially different from the typical Real Python article. I wanted the book to be as welcoming to new readers as possible but also feel familiar to the existing Real Python audience.
The target audience for Python Basics is beginner programmers interested in learning Python. You don’t need any prior programming experience to get the most out of Python Basics.
The book walks you through the process of installing Python on Windows, macOS, or Ubuntu Linux. But you can follow along on any system you like that has access to Python 3.6 or greater.
You don’t even need to know how to use a code editor! Python comes with a lightweight editor called IDLE that’s great for beginners. If you do have an editor that you enjoy using, then you can use that with the book, too. There’s only one chapter in the book that requires IDLE, and it has to do with using IDLE’s Debug window.
Python Basics covers everything you need to know about getting started with Python, including:
- Creating variables
- Working with numbers and doing basic mathematical operations
- Working with data structures like strings, lists, tuples, and dictionaries
- Writing conditional statements, functions, and loops
- Creating classes and user-defined objects
But that’s really just the beginning. After you’ve learned the basics of the language, there are chapters that teach you how to:
- Work with files
- Install and use third-party libraries
- Create and modify PDF files
- Scrape data from the Internet
- Make charts and graphs from data
- Build graphical user interfaces
Nearly every chapter has exercises with solutions, challenge problems to encourage you to take your skills to the next level, and interactive quizzes to help validate everything you learned.
Ricky: How did you find the process of writing such a comprehensive book? Has it changed how you write your technical tutorials and articles? And what did you learn that surprised you or that you now use all the time?
David: Writing the book was a lesson in endurance and perseverance. It took a little over two years to completely put together.
During that time, I switched jobs and started working full time for Real Python. I also experienced several personal trials. My house flooded twice, and my family spent over seven months displaced in 2019. That was a real challenge.
Writing the book forced me to put a lot of thought into how chapters and sections are organized. That is something that has definitely carried over into the technical articles. I’ve always been a fan of outlining, but now I can’t image writing anything without first devising an outline.
I’ve also become a big proponent of vertical lists, which are something you see all over Real Python. I have to give credit to the executive editor of Real Python, Joanna Jablonski, for encouraging me to use those more and helping me to see their value.
At first, I was a bit opposed to them. That is to say, I felt that Joanna wanted me to overuse them. In retrospect, early drafts with fewer vertical lists look ugly to me now and seem difficult to read.
Ricky: Among all the other things that you do, you’re also the cocurator of PyCoder’s Weekly. You get to read and parse hundreds of Python-related articles each week, so it’s hard to imagine that it wouldn’t benefit your own learning. Have there been moments in which the penny dropped, or you’ve read a tutorial that has had a significant impact on your own programming?
David: PyCoder’s has absolutely benefitted me both as a programmer and as a writer.
Probably the biggest takeaway from curating articles for PyCoder’s Weekly is how broad a topic the subject of Python programming is. Some of my favorite articles are about exotic things like creating Python packages that are written entirely in Rust or design patterns I’d never heard of, such as sans I/O.
I’ve also grown fond of several authors, to the point that I get excited when I see a new article published by them. I really enjoy the news dispatches written by Jake Edge over at LWN. I also look forward to articles by Brett Cannon.
Sometimes it’s the simple things that you rediscover, or just missed all together, that have the most impact. One of Brett’s recent articles reminded me about running a Python command from the terminal using the
-c flag, which I had completely forgotten about and have started using much more regularly now to check tiny code examples.
I love keeping tabs on all the wonderful packages out there in the Python ecosystem. I’ve found all sorts of amazing things, including libraries for working with NASA space data, autonomous robot simulators, and a Python-powered microscope built with LEGO.
Pythonistas are a creative bunch!
Ricky: Now for my last few questions. What else do you get up to in your spare time? What other hobbies and interests do you have aside from Python and programming?
David: I have two kids, including a four-year-old. What is this “spare time” thing you speak of?
If I’m not working and not busy adulting, then I really enjoy building LEGO, especially the space-themed sets. My oldest daughter and I enjoy stargazing and watching NASA and SpaceX rocket launches together.
I’m also a huge Star Trek fan, and I consume a lot of Star Trek content. Spock has always been one of my favorite characters. I admire his ability to balance emotion and logic.
While I don’t strive to be as emotionless as the typical Vulcan, the ability to make decisions based on reason and the best available data without letting emotion cloud your judgment is a valuable skill. I wish it were an easy thing to develop, though!
Ricky: Thank you, David. It’s always a pleasure talking to you.
If you’d like to get in touch with David, then you can find him on Twitter, or you can stop by his personal website. If you’re new to Python and would like to add some structure to your learning, then Python Basics: A Practical Introduction to Python 3 can help you level-up your Python.
If there is someone in the Python community that you’d like me to interview, then leave a comment below or reach out to me on Twitter. Happy coding!