sovabids.misc

Module with misc utilities for sovabids.

Attributes

Functions

handle_unicode_dashes()

Replace Unicode dash characters in sys.argv with regular hyphens.

flat_paren_counter(string)

Count the number of non-nested balanced parentheses in the string. If parenthesis is not balanced then return -1.

get_num_digits(N)

Return the number of digits of the given number N.

Module Contents

sovabids.misc._UNICODE_DASHES
sovabids.misc.handle_unicode_dashes()[source]

Replace Unicode dash characters in sys.argv with regular hyphens.

Word processors and some terminals substitute hyphens with typographic dashes (em dash, en dash, etc.). This causes cryptic argparse errors. Call this before parse_args() in every CLI entry point.

sovabids.misc.flat_paren_counter(string)[source]

Count the number of non-nested balanced parentheses in the string. If parenthesis is not balanced then return -1.

Parameters:

string (str) – The string we will inspect for balanced parentheses.

Returns:

The number of non-nested balanced parentheses or -1 if the string has unbalanced parentheses.

Return type:

int

sovabids.misc.get_num_digits(N)[source]

Return the number of digits of the given number N.

Parameters:

N (int) – The number we want to apply the function to.

Returns:

The numbers of digits needed to represent the number N.

Return type:

int