On Mon, Jul 19, 2010 at 10:18, ALAN GAULD <[email protected]> wrote:
> Wikipedia is a little more helpful but not Python oriented:
>
> http://en.wikipedia.org/wiki/Printf#printf_format_placeholders
Yes, that's helpful.
Say, I found a use for that asterisk in this little function I just wrote:
def sig_digits(n,digits):
"""
Return any real number n to d significant digits.
"""
return '%.*g' % (digits, n)
n = -12.22345**.978
digits = 5
x = sig_digits(n, digits)
print(x)
OUTPUT: -11.568
Dick
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor