list comprehension: >>> a= [ 1.1111, 2.2222, 3.3333] >>> [ round(x,2) for x in a] [ 1.11, 2.22, 3.33]
if you're rounding these values for the sake of printing them out then you should use: >>> [ '%.02f' % x for x in a] ['1.11', '2.22', '3.33'] On Feb 24, 2009, at 9:41 PM, barakooda wrote: > > that what i did > but there is function that deal automatically with list or touple ? > that was my question basically > > > On 25 פברואר, 00:59, Chad Dombrova <[email protected]> wrote: >> python to the rescue: >> >> >>> round( 1.24343, 2) >> 1.24 >> >> On Feb 24, 2009, at 7:31 PM, barakooda wrote: >> >> >> >>> for example i have A=(1.2323,1.3232,1.454 >> >>> i`m looking for automate function that will output same A but with 2 >>> decimal points less >> >>> the new A will be: >>> 1.2,1.3,1.4) >> >>> i can do it manually but in my script it wont be fun at all :-) >>> thank you !!! >> >> > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
