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:
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 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…
In this tutorial, we’ll make a discord bot that can play music in the voice channels. Discord is an instant messaging and digital distribution platform designed for creating communities. Users can easily enter chat rooms, initiate video calls, and create multiple groups for messaging friends.
We’ll skip the basics and jump straight over to the music playing part. Check out the following Medium article to catch up on the basics of setting up your bot:
The final result, our bot playing music on the voice channel, will look like this:
When working with code, it’s vital to use a powerful and responsive editor, or better yet, an IDE. A good IDE offers improved code organization, a fluent workflow, and powerful features to make life easier. One such tool is VSCode, created by Microsoft and freely available for anyone to download.
IDE stands for “Integrated Development Environment.” In more human terms, an IDE is a programmer’s playground. Most IDEs are backed by a community of contributors that build extensions for the IDEs. …
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…