5 Things You Should Know Before You Pick Up Python

Things to Know Before You Pick Up Python Featured Image

Summer has been very busy for me, so I thought a light list post about one of my favorite languages might be in order. So, if you’ve ever been interested in picking up Python, these are the things I might warn you about.

Table of Contents

Python Tips for New Folks

In no way is this list exhaustive, but here are a few things that came to mind to me as I continue to use Python regularly. Your mileage may vary.

Dependency Management Is a Mess

I’m not sure how well other languages handle dependency management, but I find the pip ecosystem to be a bit of a mess. Sure, it’s easy to download packages and start using them. But, if you ever want to get serious about development, you’ll probably run into a lot of problems.

A common problem beginners will notice is that they can’t have multiple versions of the same package on their system. Therefore, if two projects require two different versions of the same package, they’ll end up stuck. There are workarounds for this like creating virtual environments for each project, but these “solutions” aren’t exactly beginner friendly.

Fortunately, there are some folks who have tried to solve the dependency management problem in Python by providing third-party tooling. The one I most recently adopted is Poetry, so I recommend checking that out.

Python Is Designed to Be Idiomatic

A hurdle for a lot of folks with C-style programming experience—whether that be Java, JavaScript, C++, C#, etc.—is that Python doesn’t lend itself too well to traditional imperative programming. The reason for this is that Python is often described as an idiomatic language, meaning there are certain ways of using the language that are generally preferred by the community.

For example, many C-style languages have multiple different ways of solving a problem by providing several different interchangeable structures (e.g., for-loops, while-loops, do-while-loops, and for-each-loops). In Python, for-loops don’t really exist. Instead, for-each-loops exist, where indices can only be accessed through the enumerate() function.

Another good example of the idiomatic nature of Python is the tendency to have expressions that opt for high-level readability over low-level flexibility. For instance, when checking if a number is between two values, we can leverage the types of expressions we learned in grade school (e.g., 4 < 5 < 6) rather than the more traditional way of comparing booleans (e.g., 4 < 5 && 5 < 6).

Yet another idiom I might point to is the preference for key data structures like dictionaries and tuples over custom objects. These data structures are built so natively into the language that they’re often used in place of proper objects. And because these data structures are so ingrained in the language design, there are syntactic elements that replace common method calls. For instance, rather than calling a method like contains() on a data structure (e.g., x.contains(y)), we can use the in keyword directly (e.g., y in x).

All of this is to say that the transition to Python can have a bit of a learning curve despite how easy the language is to use. If you’re one of these folks, I tried to write a guide on how to transition from Java to Python that you may find useful (even if you don’t use Java).

Your Python Version Matters

From some of the language ecosystems I’ve seen, it’s common for the development team to provide support for very old versions of their language. For instance, Oracle provides indefinite support for all versions of Java going back to 2011. Realistically, however, they are specifically supporting Java 8 until 2030 (or later), which is longer than they’re willing to support Java 11 and Java 17.

On the flip side, Python receives a major version update once a year. Each major version is valid for 5 years before support is dropped. At the time of writing, Python 3.7 will no longer be supported as of June 27th, 2023.

Personally, I like this workflow quite a bit. It forces the surrounding ecosystem to be maintained and improved. It also gives a five year window for new features to become stable in the language, allowing folks to actually use these new features without worrying about backwards compatibility. For instance, in Python 3.8, they added the walrus operator. By the end of next month, you can freely use that syntax in all your projects without feeling bad for the folks using Python 3.7.

Of course, if you’re still unsure where to start, I have a deeper guide on how to pick a Python version.

Python Isn’t Great for Object-Oriented Programming

When you first pick up Python, you’ll find it’s lightweight design easy to learn and use. After all, you can start putting together scripts using basic programming knowledge right now. However, if you come from an object-oriented programming (OOP) background, you’ll find that there’s a lot to be desired.

For instance, if you have a Java or C# background, you might already be used to using OOP features like interfaces and abstract classes. You might also enjoy features like being able to hide the internal implementation details through private members. Unfortunately, Python doesn’t really support these features without making use of some more niche modules, such as dataclass or abc.

Another quirky OOP feature of Python is the ability to add fields to an object after it has already been initialized, much like objects in JavaScripts. And since Python encourages working with fields directly, you’ll find that it’s almost normal for objects to not always have fields that you might expect. Further, any instance methods you define for an object must accept the self parameter, which is implicitly included when called. Otherwise, none of the fields can be accessed.

All that being said, objects are used all the time in Python. In fact, I’ve designed a few libraries of my own around them, such as SnakeMD. You just have to get used to the lack of strict constraints that are enforced in other programming languages.

Low-Level Programming Concepts Are Abstracted

If you’re an absolute beginner (and I apologize for this jargon loaded article), there are a lot of key programming concepts that are going to be abstracted away for you. This in general is a good thing, in my opinion. It allows you to get a handle on problem solving without concerning yourself with how the computer is getting the job done.

However, the consequence of using Python is that you’re not going to learn how software works. And this is true for a lot of modern programming languages, but I find Python to be a bit more egregious.

For example, if you use Python, you will most likely never think about memory management. When you create variables and objects, Python will handle all of the memory for you under the hood. There will be almost no opportunity where you will be manually requesting memory from the operating system or giving that memory back.

In a more practical example, the core number system in Python completely abstracts our understanding of how numbers work in the computer. In most programming languages, numbers can have a variety of types (e.g., int, float, etc.). Therefore, you need to know which type to choose to accomplish your task. Further, these numbers have limits (e.g., an integer maxes out at just over 2 billion). With Python, you don’t have to think about this. You can use most numbers how you might use them in mathematics.

Overall, I think hiding some of the machine internals is an overwhelming net positive for folks who want to write software. No longer do you have to consider things like appropriate line endings or numerical types. You can just write code. However, you may find that transitioning to a lower level language requires a bit of a learning curve.

Summary

As someone who uses Python everyday, I find myself constantly singing its praises. However, when I sat down with a student who took my advice to check it out, I was reminded of the many annoyances we don’t warn folks about. As a result, I figured I’d take a moment to be a little honest for once about my favorite programming language.

With that said, if you want to see all of the positive things I have to say about Python, check out some of these articles:

Likewise, here are some additional resources (#ad):

Otherwise, all I’ll say is thanks again for sticking around. Hope to see you around here again soon!

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife, playing Overwatch and Phantasy Star Online 2, practicing trombone, watching Penguins hockey, and traveling the world.

Recent Posts