Subtracting years from a date in Python

The easiest way to subtract years from a date in Python is to use the dateutil extension. Install it with pip: pip install python-dateutil The relativedelta object from the dateutil.relativedelta module allows you to subtract any number of years from…

Adding years to a date in Python

The easiest way to add years to a date in Python is to use the dateutil extension. Install it with pip: pip install python-dateutil The relativedelta object from the dateutil.relativedelta module allows you to add any number of years to…

How to subtract months from a date in Python

The easiest way to subtract months from a date in Python is to use the dateutil extension. Install it with pip: pip install python-dateutil The relativedelta object from the dateutil.relativedelta module allows you to subtract any number of months from…

Adding months to a date in Python

The easiest way to add months to a date in Python is to use the dateutil extension. Install it with pip: pip install python-dateutil The relativedelta object from the dateutil.relativedelta module allows you to add any number of months to…

Beware of excess of “best practices”

Unlike other disciplines that are more rigid and regulated like Civil Engineering, Software Engineering doesn’t have a set of rules to follow by law enforcement. You won’t go to jail if you don’t do TDD (Test-Driven Design), or even write…

The hard part is to continue

Starting out is easy, the hard part is to continue. Anything for a while is easy: Work out for a while Study for a while Diet for a while Work right for a while Take good care of the family…

Python list drop duplicates

Removing duplicates from a list is a task that might happen more often than you think. Maybe you are importing a bunch of rows from a CSV file and want to make sure you only have unique values. Or you…

Learning Programming is Non-Linear

Learning is by no means a linear process, even in hard sciences like Math. It is very common to see people asking in groups, Reddit, and other forum-like places "What path should I take to become a Software Developer". Unfortunately,…

Python for loop increment by 2

A regular for loop will increase its iteration counter by one in each iteration. But there are situations where you want to increment the iteration counter by 2. For some reason you might want to work with only even values.…

Python 1 line for loop

Instead of using the same old way of iterating through lists, we can make our code simpler by using list comprehensions, which allow us to make a 1 line for loop in Python. Basic syntax of a 1 line for…