how to get the most recent previous business day in python

from datetime import datetime, timedelta

today = datetime(2022, 5, 1)
today

#output
datetime.datetime(2022, 5, 1, 0, 0)
# equation to find time elapsed
offset = max(1, (today.weekday() + 6 ) % 7 - 3 )
offset

# output
2
time_delta = timedelta(offset)
time_delta
# output
datetime.timedelta(days=2)
# subtract two datetime objects
most_recent = today - time_delta
most_recent

#output
datetime.datetime(2022, 4, 29, 0, 0)