Black is a code formatter that automatically adjusts your Python code after a well-defined rule set. In this article, I discuss the need for such a code formatter, show you how to integrate it into your IDE and also into your CI pipeline. Why you want to use a code formatter When you are a developer working as part of a team on a large project, you might have already realized there are different opinions on how particular structures in ...
Context When developing Django web applications, one of the most popular ways to debug the performance of database queries, the values of internal variables or other custom metrics is the django-debug-toolbar. To integrate the toolbar into a Django web application, one first needs to configure a list of internal IP addresses. Only if the IP address of the web browser accessing the web application is part of this list, the toolbar will be shown. Otherwise, the toolbar is hidden (even ...
Problem: When writing HTML templates for the Django Python framework, you want to use Visual Studio Code’s auto formatting features. However, when you activate the auto-format functionality, VSCode complains that there is no formatter available for such HTML files: “There is no formatter for ‘django-html’ files installed.” Solution: First, install the beautify extension. Then, open the settings.json by pressing SHIFT - CMD - P and enter “Open Settings (JSON)”: Next, add the following block to your settings.json: "files.associations": { "**/*.html": ...
In this post, I am showing you how to use the freely available Open Weather Map API to retrieve hourly weather forecasts 48 hours into the future for a given place using Python without external packages. Continue reading if you need an easy and flexible way to obtain weather data in your python application and you want to avoid using third-party dependencies for the task. You will use the free tier of the Open Weather Map API. The resulting weather ...
Measuring code execution times is hard. Learn how to eliminate systematic and random measurement errors and obtain more reliable results. We often need to measure how long a specific part of code takes to execute. Unfortunately, simply measuring the system time before and after a function call is not very robust and susceptible to systematic and random measurement errors. This is especially true for measuring very short intervals (< 100 milliseconds). Systematic and Random Errors So what is wrong with ...