Oftentimes values in settings.py
are provided using environment variables. This is one of the easiest ways to do it. However it’s easy to misuse it, and variables get scattered across your code base. This makes it harder for DevOps to track which variables are needed in case they need to have a quick look at the code while configuring the deployment environment.
Filter, Map, Reduce and Lambdas
Filter, map, and reduce are functions that are often used in functional programming. Sometimes instead of looping, you can use one of these functions to write a simple one liner. Additionally, when using this functions, we also naturally use lambdas. So first, we’ll take a look at what are lambdas.
[Read More]What is self in Python
self
is usually one of the hardest things for beginners to grasp. It is one of those concepts that you probably need to google about several times before you start to get any idea + you have to try it out and use it to fully understand it.
Python Beginner Projects
If you are beginner trying to learn and build your confidence than this article is for you.
[Read More]Else Is Not for Ifs Only
We all know what else
means in control flow. But in Python else
can appear on loops and on try/except statements. But what does it do there?
getattr() vs __getattr__ vs __getattribute__
There are three methods that are often confusing to the beginners: getattr()
, __getattr__
, and __getattribute__
. This article will try to clear the confusion between these three methods.
Learn Python in 15 Minutes
But only if you can read and learn really fast.
[Read More]Enum in Python
Enum is a collection of symbolic names and its values are unique and constant. In essence enums are collection of constants.
You can use enum when you have a specific string or integer appearing in several places in the code. By placing enum instead of a string, you would avoid possible errors that could be result of typos in your code.
[Read More]Up and Running With Python Logging Facility
Python comes bundled with logging module. This module is very versatile, and feature rich. However, as a beginner, you mostly want to just get up and runnig, and use the logger in the most simple way. Luckally, logging in Python does not have to be hard and painful.
[Read More]How to Use pip-tools
After it became obvious that pipenv
is dead (and had a lot of problems) I’ve decided to swtich to an alternative. Enter pip-tools
.