<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def best_representative(d1, d2):
 """ Given two objects each coerced to the most specific type possible, return the one of the least restrictive type. Decimal('-99.9999') Decimal('6.1') '48-490' 'foo' Decimal('9.99') Decimal('-9.9') """

  
    if hasattr(d2, 'strip') and not d2.strip():
        return d1
    if d1 is None:
        return d2
    elif d2 is None:
        return d1
    preference = (datetime.datetime, bool, int, Decimal, float, str)
    worst_pref = 0
    worst = ''
    for coerced in (d1, d2):
        pref = preference.index(type(coerced))
        if pref > worst_pref:
            worst_pref = pref
            worst = set_worst(worst, coerced)
        elif pref == worst_pref:
            if isinstance(coerced, Decimal):
                worst = set_worst(worst, worst_decimal(coerced, worst))
            elif isinstance(coerced, float):
                worst = set_worst(worst, max(coerced, worst))
            else:  # int, str
                if len(str(coerced)) > len(str(worst)):
                    worst = set_worst(worst, coerced)
    return worst