code: def in_words(amount, gender=None):
      
      check_positive(amount)
      if isinstance(amount, Decimal) and amount.as_tuple()[2] == 0:
          # если целое,
          # т.е. Decimal.as_tuple -> (sign, digits tuple, exponent), exponent=0
          # то как целое
          amount = int(amount)
      if gender is None:
          args = (amount,)
      else:
          args = (amount, gender)
      # если целое
      if isinstance(amount, six.integer_types):
          return in_words_int(*args)
      # если дробное
      elif isinstance(amount, (float, Decimal)):
          return in_words_float(*args)
      # ни float, ни int, ни Decimal
      else:
          # до сюда не должно дойти
          raise TypeError(
              "amount should be number type (int, long, float, Decimal), got %s"
              % type(amount))
docs: Numeral in words
  
      @param amount: numeral
      @type amount: C{integer types}, C{float} or C{Decimal}
  
      @param gender: gender (MALE, FEMALE or NEUTER)
      @type gender: C{int}
  
      @return: in-words reprsentation of numeral
      @rtype: C{unicode}
  
      raise ValueError: when amount is negative