def previous_friday ( dt ) : if dt . weekday ( ) == 5 : return dt - timedelta ( 1 ) elif dt . weekday ( ) == 6 : return dt - timedelta ( 2 ) return dt
python set weekend as workday
If holiday falls on Saturday or Sunday use previous Friday instead .
def previous_friday(dt):
    """
    If holiday falls on Saturday or Sunday, use previous Friday instead.
    """
    if dt.weekday() == 5:
        return dt - timedelta(1)
    elif dt.weekday() == 6:
        return dt - timedelta(2)
    return dt