Yes it is a problem with your python version. Add an external pair of parenthesis:
print(
('{0:.%df}' % min(30, int(digits))).format(4 * (4 * atan(1.0/5.0) - atan(1.0/239.0)))
)
This is because in python3 print
is a function and that expression is parsed as:
(print('{0:.%df}' % min(30, int(digits)))).format(...)
In other words print
gets a single argument which is:
'{0:.%df}' % min(30, int(digits))
and the .format
is called on the return value of the print
call which is always None
.
In python2, where print
is a statement, everything is passed as an argument to the statement and thus the outer parenthesis aren't required.
Side note: you can avoid using the %
formatting, since you can nest the formattings:
print('{0:.{1}f}'.format(4 * (4 * atan(1.0/5.0) - atan(1.0/239.0)), min(30, int(digits))))
Or maybe better:
print('{value:.{prec}f}'.format(prec=min(30, int(digits)), value=4 * (4 * atan(1.0/5.0) - atan(1.0/239.0))))