Numbers

cut(string, characters=2, trailing='normal')

Split a string into a list of N characters each.

reusables.cut("abcdefghi")
# ['ab', 'cd', 'ef', 'gh', 'i']

trailing gives you the following options:

  • normal: leaves remaining characters in their own last position
  • remove: return the list without the remainder characters
  • combine: add the remainder characters to the previous set
  • error: raise an IndexError if there are remaining characters
reusables.cut("abcdefghi", 2, "error")
# Traceback (most recent call last):
#     ...
# IndexError: String of length 9 not divisible by 2 to splice

reusables.cut("abcdefghi", 2, "remove")
# ['ab', 'cd', 'ef', 'gh']

reusables.cut("abcdefghi", 2, "combine")
# ['ab', 'cd', 'ef', 'ghi']
Parameters:
  • string – string to modify
  • characters – how many characters to split it into
  • trailing – “normal”, “remove”, “combine”, or “error”
Returns:

list of the cut string

int_to_roman(integer)

Convert an integer into a string of roman numbers.

Parameters:integer
Returns:roman string
int_to_words(number, european=False)

Converts an integer or float to words.

Parameters:
  • number – String, integer, or float to convert to words. The decimal can only be up to three places long, and max number allowed is 999 decillion.
  • european – If the string uses the european style formatting, i.e. decimal points instead of commas and commas instead of decimal points, set this parameter to True
Returns:

The translated string

roman_to_int(roman_string)

Converts a string of roman numbers into an integer.

Parameters:roman_string – XVI or similar
Returns:parsed integer