def to_decimal(x):
 try:
  return D(x)
 except TypeError:
  return D(('%0.54f' % (x,)))

def to_decimal ( x ) : try : return D ( x ) except TypeError : return D ( ( '%0.54f' % ( x , ) ) )
see if d(x) returns something .