In this article, you can find some tips to avoid common errors in Python3 and some insights into the Pythonic way of writing programs. We are going to talk about function default arguments, walrus operator, and formatting expressions.
Sometimes you may need to use a non-static type as a default argument value. For example, let’s imagine we need to define a function that prints a given message, and we want to include information about when the function was called (a sort of log function).
from datetime import datetime
from time import sleep
def print_time(when: datetime = datetime.now()): …