Do you know how to force keyword arguments, create a function decorator, create anonymous functions, or unpack an array or dictionary into a function’s arguments? Here are four advanced tricks regarding Python functions.
Keyword arguments have several advantages:
Python is awesome! So why do people hate Python? After some highly non-scientific, Internet-based research, these are the reasons I encountered most often. I found many more, but most of them were so ridiculous that I wouldn’t even dare to repeat them here.
I won’t link to sources or apply naming and shaming. Consider this read just for fun, but with an educational touch!
Disclaimer: no feelings or programmers were hurt while writing this article, but some feelings might get hurt while reading it. If you have a heart condition and love Python, perhaps you better skip this one.
A Bloom filter efficiently tests if an element is a member of a set. It was first proposed by Burton Howard Bloom all the way back in 1970. Although a little unknown, they have become ubiquitous, especially in distributed systems and databases. Bloom filters are an excellent time and memory saver.
After reading this article, you’ll know:
I’ll illustrate with practical Python-based example code. The examples will be so easy to understand that non-Python programmers should have no problem following them.
We’ll dive right in with a…
Why do we all love Python? For starters, it’s a beautiful and easy-to-learn programming language. Another reason: it comes with batteries included, meaning Python has many excellent libraries included by default. But in my opinion, it’s the 230,000 user-contributed packages that make Python really powerful and popular.
In this article, I handpicked 15 packages that I found most useful during my 10-year career as a Pythonista. Let’s go!
Dash is relatively new. It’s ideal for building data visualization apps in pure Python, so it’s particularly suited for anyone who works with data. Dash is a blend of Flask, Plotly.js, …
Python ships with a powerful and elegant JSON library to help you decode and encode JSON. It can be imported with:
In mathematics, there’s a concept called set-builder notation, also called set comprehension. Inspired by this principle, Python offers comprehensions, too. In fact, list comprehensions are one of the defining features of Python. They allow us to create concise, readable code that outperforms the uglier alternatives like
for loops or using
We’ll first look at the most well-known type: list comprehensions. Once we’ve got a good grasp of how they work, you’ll also learn about set comprehensions and dictionary comprehensions.
A list comprehension is a language construct. It’s used to create a list based on an existing list. Sounds a…
How is Python being used around the globe and across industries?
This question inspired me to write this piece. I figured a list of the most-used Python packages would give a good indication.
As a starting point, I took a list of the most downloaded Python packages on PyPI over the past 365 days. Let’s dive in and find out what they do, how they’re related, and why they rank so high!
Urllib3 is an HTTP client for Python that brings many features that are missing from the Python standard libraries:
Concurrency is working on multiple things at the same time. In Python, this can be done in several ways:
threading, by letting multiple threads take turns.
multiprocessingwe’re using multiple processes. This way we can truly do more than one thing at a time using multiple processor cores. This is called parallelism.
Concurrency is working…
There are lots of little tricks that can make life easier for a Python coder. Some of these will be known to you, but I’m sure there are at least a couple that you haven’t seen before.
If you’re done reading, also take a look at our latest article on concurrency:
Iterators make for very elegant for-loops in Python, and also make comprehension possible. Even though it requires some work to understand all the inner workings, they are actually very easy to use in practice!
To understand what a Python iterator is, you need to know two terms:
Iterator — An object that can be iterated, meaning we can keep asking it for a new element until there are no elements left. Elements are requested using a method called
Iterable — An object that implements another special method, called __iter__. This function returns an iterator.
As stated above, a Python…