According to a recent StackOverflow analysis Python is the fastest growing programming language of those already in wide use. What's more, the growth rate is accelerating, and has been consistently for the past few years. While the specific conclusions of the StackOverflow post should probably be taken with a grain of salt, there's no denying the fact that Python use has exploded over the past five years. That's great news for people who have long used and enjoyed the language, but it's still important to ask why Python usage has exploded. And the primary, if not sole facilitator of this growth is a feature of the language you've probably never even heard of.
Note: Each day this week I'm going to republish one of my most popular posts. My hope is that people who missed them the first time might find them useful now. This post, on "classes" and Object Oriented Programming remains my most popular post of all time. I've gotten hundreds of emails about this post alone. Many have found it an accessible introduction to classes and OOP, both in Python and in general.
class is a fundamental building block in Python. It is the underpinning
for not only many popular programs and libraries, but the Python standard library as
well. Understanding what classes are, when to use them, and how they can be
useful is essential, and the goal of this article. In the process, we'll explore
what the term Object-Oriented Programming means and how it ties together with
A Python project I'm working on at Enigma is starting to grow rather large. I spent a good deal of
effort yesterday getting a five line change added to our
Makefile (which is run as part of our CI and CD pipeline on
every pull request and merge). After the PR was merged, I gloated to others how awesome my team's project was. Here are
the five lines:
lint: pylint --rcfile=.pylintrc api -f parseable -r n && \ mypy --silent-imports api && \ pycodestyle api --max-line-length=120 && \ pydocstyle api
For completeness sake, here is the
test target that actually gets run as part of CI tests:
test: install lint python3 setup.py test --addopts="--cov=api" coverage xml -i -o coverage/cobertura-coverage.xml --omit=$(VIRTUAL_ENV)/*,.eggs/*
(So, for those not versed in "Makefile-ese", the
test target won't run successfully if the
lint target doesn't do so
Why was I happy enough to be a jerk to other engineers and brag about those five lines? It all comes down to complexity.
Before we begin, let's be clear on terminology. When I refer to "working with data" in the context of software development I could mean one of two things:
- Interactively working with data, with perhaps Jupyter (née IPython) or the live interpreter
- Writing, testing, reading, reviewing and maintaining programs that primarily manipulate data
In short: Python is awesome for interactive data analysis but terrible for writing long-lived programs dealing with complicated data structures.
After an unplanned two-year hiatus, the fourth video in the Writing Idiomatic Python Video Series is out! This was long overdue, and for that I sincerely apologize. All I can do now is continue to produce the rest at a steady clip and get them out as quickly as possible. I hope you find the video useful! Part 5 will be out soon...