def parse_decimal_string(s):
 if (isinstance(s, six.integer_types) or isinstance(s, Decimal)):
  return Decimal(s)
 if isinstance(s, float):
  return Decimal(str(s))
 s = s.strip().replace(' ', '')
 if (not s):
  return Decimal(0)
 if (',' in s):
  if ('.' in s):
   s = s.replace(',', '')
  else:
   s = s.replace(',', '.')
 return Decimal(strip_non_float_chars(s.strip()))

def parse_decimal_string ( s ) : if ( isinstance ( s , six . integer_types ) or isinstance ( s , Decimal ) ) : return Decimal ( s ) if isinstance ( s , float ) : return Decimal ( str ( s ) ) s = s . strip ( ) . replace ( ' ' , '' ) if ( not s ) : return Decimal ( 0 ) if ( ',' in s ) : if ( '.' in s ) : s = s . replace ( ',' , '' ) else : s = s . replace ( ',' , '.' ) return Decimal ( strip_non_float_chars ( s . strip ( ) ) )
parse decimals with "best effort" .