If you’re stuck at home, now is the time to polish your skills

Image by author

1. Create a game

I bet you never considered creating a game with Python. But why not? There are awesome libraries that will help you develop games. So let’s help your kids, your partner, or your colleagues get through this crisis with a fun game!

Pygame

Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries. Here are a few tutorials you can try:


Get off to a good start with these helpful tips and learning tactics

Image by author

Getting started is hard, no matter what subject it is. To prevent getting discouraged early on, I’m sharing these tips to optimize your learning path.

1. Dive into the basics

You’d think the Python website itself would contain a good tutorial like most other languages do. However, they mostly link to other sites or dive in deep, assuming you are a seasoned programmer already.

Python Land offers a free and easy to follow introduction to the language, with topics like:

  • Python’s history (the language is actually quite old!)
  • Installation instructions
  • A beginner's tutorial to Python covering basics like variables, functions, for-loops, etcetera

If you prefer…


6 tips to keep your body and mind healthy during this pandemic

Photo by Nubelson Fernandes on Unsplash

Extended periods of sitting increase your risk of chronic health problems, such as heart disease, diabetes, and cancer. It can also be bad for your mental health.

It’s essential to develop healthy habits as early as you can to counter these risks. I’ll share six crucial tips that helped me improve my health as a software developer.

1. Get Enough Quality Sleep

Sleep is underrated. It’s the foundation of your health. So why do we need it so badly? There are various reasons — these are a few found by scientists:


YAML is easy to write for humans and easy to read by computers

YAML, a recursive acronym for “YAML Ain’t Markup Language”, is a human-readable data serialization language. It is often used for configuration files, but can also be used for data exchange. The most used python YAML parser is PyYAML, a library that allows you to load, parse, and write YAML, much like Python’s JSON library helps you to work with JSON.

In this article, I’ll share six tricks to effectively and securely use this library. But first, we’ll explore why you should use YAML in the first place.

Why use YAML with Python?

YAML is easy to write and read for humans, while at the same…


Using the subprocess library the right (and safe) way

Image by author

Despite the many libraries on PyPI, sometimes you need to run an external command from your Python code. The built-in Python subprocess module makes this relatively easy.

In this article you will:

  • Learn the basics about processes and sub-processes
  • Use the Python subprocess module to safely execute external commands
  • Capture the command’s output
  • Feed a command with input from standard in
  • Look into running shell commands
  • Learn about critical security considerations when running external commands

1. Processes and subprocesses

A program that is executed on a computer is also called a process. But what is a process, exactly? Let’s define it more formally:

Process…


From forcing keyword arguments to anonymous functions

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.

1. Forced Keyword Arguments

Keyword arguments have several advantages:

  • You’re not forced into a particular order in which you supply your arguments. The name matters — not the position.
  • Keyword arguments provide clarity. Without looking up the function itself, you can often guess what the argument is used for by looking at the names.

That’s nice, but you probably already knew these things. What you might not know is that you…


And all the reasons why they are wrong

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.

1. Indentation instead of curly braces

Many…


What is it, when to use, with Python example code

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:

  • What Bloom filters are
  • Why and when you can use a Bloom filter

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.

Bloom filter in Python

We’ll dive right in with a…


A handpicked list of the most useful and surprising Python packages from PyPI

Image by author

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!

1. Dash

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, …


JSON in Python is easy; get up and running quickly

JSON, short for JavaScript Object Notation, is an open standard. Although its name doesn’t imply so, it is a language-independent data format. JSON is used to both store and exchange data. It’s a prevalent data format because it is easy to read and write for humans too. Working with JSON in Python is super easy! Python has two data types that, together, form the perfect tool for working with JSON in Python: dictionaries and lists.

Importing the JSON library in Python

Python ships with a powerful and elegant JSON library to help you decode and encode JSON. It can be imported with:

import json

This library…

Erik van Baaren

Software developer by day, writer at night. Webmaster at https://python.land

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store