API Reference

genutils.strings

Some functions helping with string encoding and decoding.

genutils.strings.to_bytes(str_or_bytes, encoding='utf-8)')[source]

Take argument and return as bytes.

Parameters:
  • str_or_bytes (str or bytes) – argument to encode.
  • encoding – the encoding to use if argument is of type str
Returns:

argument as bytes

Return type:

bytes

genutils.strings.to_str(str_or_bytes, encoding='utf-8')[source]

Take argument and return as unicode string.

Parameters:
  • str_or_bytes (str or bytes) – argument to decode.
  • encoding – the encoding to use if argument is of type bytes
Returns:

argument as unicode string.

Return type:

str

genutils.tbnumbers

Some utilities related to numbers.

genutils.tbnumbers.is_even(num)[source]

Is num even?

Parameters:num (int) – number to check.
Returns:True if num is even.
Return type:boolean
Raises:TypeError if num is not an int.
genutils.tbnumbers.is_odd(num)[source]

Is num odd?

Parameters:num (int) – number to check.
Returns:True if num is odd.
Return type:boolean
Raises:TypeError if num is not an int.