Sitemap
Better Programming

Advice for programmers.

Member-only story

5 Common Anti-Patterns in Python

6 min readApr 16, 2021

--

Code on a laptop screen
Photo by Luca Bravo on Unsplash

“It’s not enough for code to work.” — Robert C. Martin

Python is one of the most popular languages in 2021.

The simple syntax makes it a popular choice for newbie programmers.

Because of the dynamic nature and flexibility, Python developers are sometimes prone to writing faulty, inefficient code.

This article will introduce readers to common anti-patterns found in Python and propose fixes that will lead to better developer practices.

1. Using map() and filter() On Iterable Objects

The inbuilt map and filter helps us transform iterable objects in Python via the principles of functional programming.

Both methods accept a function and an iterable as arguments and return a corresponding object.

This object can be transformed into a list by passing it as an argument into the inbuilt list constructor in Python.

We often use lambda functions as arguments to themap , filter functions:

--

--

Sayar Banerjee
Sayar Banerjee

Written by Sayar Banerjee

Graduate Student in Analytics at UC Davis | Data Scientist | Amateur crypto investor | UIUC Alumnus

Responses (8)