The numbering module

Functions dealing with numbering of voices, parts etcetera.


Convert an integer value to a roman number string.

E.g. 1 -> “I”, 12 -> “XII”, 2015 -> “MMXV”

n has to be an integer >= 1; raises ValueError otherwise.


Convert a string with a roman numeral to an integer.

E.g. “MCMLXVII” -> 1967, “iii” -> 3

Raises a KeyError on invalid characters.

int2letter(n, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ')[source]

Convert an integer to one or more letters.

E.g. 1 -> “A”, 2 -> “B”, … 26 -> “Z”, 27 -> “AA”, etc. Zero returns the empty string.

chars is the string to pick characters from, defaulting to string.ascii_uppercase.

letter2int(s, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ')[source]

Convert a string with letters to an integer.

E.g. “AA” -> 27

An empty string yields 0. Raises a ValueError when a character is not available in chars (which defaults to string.ascii_uppercase).


Convert an integer to the English language name of that integer.

E.g. converts 1 to “One”. Supports numbers 0 to 999999999. This can be used in LilyPond identifiers (that do not support digits).


Convert a text number in English language to an integer.

E.g. “TwentyOne” -> 21, ‘three’ -> 3

Ignores preceding other text. Returns 0 if no valid text is found.