Getting Started with Python (Again): OOP and VS Code

Last month I set a goal of dusting off my Python. While I use R exclusively at work, some recent developments in Python caught my eye, and so I thought it would be good to regain my proficiency with the language. Here are some resources that have helped me on this journey – hopefully they help other folks who are interested in improving their Python!

As I’ve written before, I am fortunate to be friends with Reuven Lerner, one of the top Python trainers in the world. In addition to running in-person trainings at large companies each week, Reuven also has an increasingly large library of online courses aimed at consumers. Since my least favorite part of R is how it handles Object Oriented Programming, I decided to sign up for his Weekly Python Exercise (WPE) A3: Object-oriented Programming course to help me reacquaint myself with how Python handles OOP. I’m 6 weeks in, and it’s been a blast. The format of getting one small problem a week, with a solution the next week, is just really effective. Several years ago (my first time learning Python) I took Reuven’s full course on OOP. So this WPE has been a good way to refresh my knowledge of this aspect of the language.

In my initial foray to Python I was content to just use Jupyter Notebooks. Notebooks are great for experimenting and iterating with little fragments of code. But as WPE has progressed, the programs we’re building have become a bit too complex for notebooks. For example, my solution to the Week 6 exercise is 7 classes over 73 lines. At that length Notebooks just stop being the best way to interact with your code. Better would be a text editor and the ability to trace through code with a debugger. WPE also comes with an automated test each week, and it would be nice to be able to run those tests without switching back and forth between the console and the text editor. This is, in short, why people created Integrated Development Environments (IDEs)!

Python IDEs

Last month the only Python IDE I knew by name was PyCharm, so I downloaded and started using it. It worked fine, but as I spoke to more friends who use Python regularly I kept on hearing about VS Code. On a whim, I decided to post a poll on LinkedIn to see which IDE is most popular in the Python world these days – the results surprised me!

It turns out that an IDE I had only recently heard of had already taken the Python world by storm. That’s technology for you: change happens fast! (PS If you’d like to connect with me on LinkedIn, click here).

Installing VS Code and going through their basic tutorial was pretty straight forward. But after a few weeks I discovered that I was basically just using it as a text editor. I only have a few hours each week to devote to Python, and all of it was getting spent on the WPE exercises themselves. There just wasn’t any time left over to figure out how to integrate PyTest into VS Code or use the debugger, even though that was what I originally downloaded it for.

As I was googling around for how to make better use of VS Code I stumbled upon the website RealPython. They actually have a course that is exactly what I was looking for: Python Development in VS Code (Setup Guide). Interestingly, this course has the complete opposite teaching style as Reuven’s. Reuven is all about exercises. When Reuven lectures, it’s to get you to the point where you can take on an exercise on your own. RealPython (both in this course and others I’ve taken) is all about succinct screencasts that you follow along with. While this teaching style is probably not the best for every situation, I think that it works very well for a “here is how to set up your new IDE” course.

R vs. Python: Object-Oriented Programming Edition

My recent work with Python’s OOP system has caused me to start thinking about how it compares to R’s OOP system. My experience is that most R users have heard of OOP, but struggle to apply it to their own work. If anyone is interested in a post summarizing how R handles OOP, and how it compares to how Python handles it, please let me know.