def toStringArray ( name , a , width = 0 ) : string = name + ": " cnt = 0 for i in a : string += "%4.2f  " % i if width > 0 and ( cnt + 1 ) % width == 0 : string += '\n' cnt += 1 return string
how to fill an array with str in python
Returns an array ( any sequence of floats really ) as a string .
def toStringArray(name, a, width = 0):
    """
    Returns an array (any sequence of floats, really) as a string.
    """
    string = name + ": "
    cnt = 0
    for i in a:
        string += "%4.2f  " % i 
        if width > 0 and (cnt + 1) % width == 0:
            string += '\n'
        cnt += 1
    return string