Back to categories

Category: "Python"

Environment Variables in Python Janne Kemppainen |

Environment variables are key-value pairs that are defined in your shell environment outside of the Python executable. You can access them in Python with the os.environ mapping object.

Environment variables are really useful for passing secret information or other configurations that you don't want to pass as command line arguments. A good use case for example is a containerized application running in Docker or Kubernetes where you can configure the application using environment variables.

Three Dots in Python, What is the Ellipsis Object? Janne Kemppainen |

You might have stumbled on the Ellipsis object (…) in Python and wondered what it is used for. It was originally introduced to be used in the Numeric Python package for matrix slicing but nothing stops you from using it for other purposes too.

Use Make to Power Up Your Python Development Janne Kemppainen |

When you think of GNU Make what is the first thing that pops up to your mind? Perhaps you remember building C or C++ programs from source and automatically associate it with languages where you need to build the code before being able to run anything.

However, Make can be a really powerful tool for your other projects too. In this article I'll show you some examples on how to utilize Make for Python development. I'll be using the Flask web framework for demonstration purposes but these principles can be really adapted to any other project.

Install Python on Windows With Virtual Environments Janne Kemppainen |

Today I wanted to install Python natively on my Windows machine. Nowadays it is super easy as python can be installed straight from the Microsoft Store. So if you need to have Python on Windows I really recommend that you go to the Microsoft Store from the Start menu, search for Python and install it from there.

Stop Worrying About Python Code Formatting

An overview of the code formatter Black

Janne Kemppainen |

Wouldn't it be nice if you didn't have to worry about code formatting to make the linter happy? What if you didn't need to complain about minor formatting issues every time you are reviewing code? Can't agree on a common code style with your team so your codebase doesn't have a consistent look and feel? You are just starting a new Python project? It might be the right time to try Black.

Code style: black

Show Twitter Follower Count with Google Spreadsheets as a Backend Janne Kemppainen |

I was quite surprised to get my first Twitter followers after linking my earlier blog post about developing with Windows Subsystem for Linux to Twitter as I've never really had a social media presence outside of my own circles. This gave me the idea to track how my Twitter following develops over time when I start from zero.

Given that I'm using a static blogging environment there is no server that could actively serve this data and routing users to my home server is definitely not an option. This is where Google Spreadsheets comes in handy as it turns out that you can fetch data in CSV format without having to use strong authentication! Read more to find out how I built the follower chart below.