Getting a number of digits
Question: I've been searching for a way in python to get only 4 digits on the right of
the comma of a decimal number, but i couldn't find. Took a look on this
post,---> [Rounding Decimals with New Python Format
Function](http://stackoverflow.com/questions/1598579/rounding-decimals-with-
new-python-format-function) ,but the function written there...

    
    
        >>> n = 4
        >>> p = math.pi
        >>> '{0:.{1}f}'.format(p, n)
        '3.1416'
    

...seems not to work in my case.

I imported the modules "math" and "decimal", but maybe i'm missing some others
to import, but i don't know which of them to import.

Thanks everyone, and sorry if this issue has already been posted.

Peixe


Answer: 
    "%.3f" % math.pi
    

I know its using the old syntax but I personally prefer it.

