defaultdict – Python dict with default values for absent keys.
Proper way to get UTC datetime is
datetime.now(timezone.utc) (docs), not
By default datetime is naive, i.e. without a timezone. Naive datetime is treated as local time. This is the source of many, many pains if not treated properly.
datetime.utcnow()is naive, surprisingly. Meaning it will be treated as local time by default.
Python evaluates default function arguments on their definition and not on each function call. Thus, do not use mutable values for default arguments
def fn(a=), unless you really need
a shot in the foota singleton. Use the following workaround:
def fn(a=None): if a is None: a = 
dataclassesin can be done with a
from dataclasses import dataclass, field @dataclass class Demo: a = field(default_factory=list)