def NumToStr(number, formatString = ''):
    """Converts number to string using an optional format string."""
    if formatString == '':
        return str(float(number))
    else:
        if not formatString[0] == '%':
            raise ValueError('invalid format string (first character should be %)')
        fmt = '{:'+formatString[1:]+'}'
        return fmt.format(float(number))