"Lance Hoffmeyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The array comes out as unicode. This is probably because I am grabbing the numbers > from a Word Doc using regex's. > > So, before rounding I perform the following: > # Convert to String > Topamax = [str(x) for x in Topamax] > # Convert to floating > Topamax = [float(x) for x in Topamax] > # Finally, round the number > Topamax= [(x+0.5) for x in Topamax] > > Is there a shorter way? > > Lance > > ... or if you prefer the functional approach (using map)...
roundToInt = lambda z : int(z+0.5) Topamax = map( roundToInt, map( float, map(str, Topamax) ) ) (Python also has a built-in round() function, but this returns floats, not ints - if that is okay, then just delete the lambda definition, and replace roundToInt with round.) -- Paul -- http://mail.python.org/mailman/listinfo/python-list