Mark Dickinson <[email protected]> added the comment:
Thanks Georg and Eric for the feedback! New wording committed in
r75289 (trunk), r75290 (py3k), r75291 (release31-maint). Leaving open
for the backport to release26-maint.
BTW, it's much easier to describe the rules in Python than in prose:
def strip_zero_dot(sig):
return sig.rstrip('0').rstrip('.') if '.' in sig else sig
def gformat(x, p=6):
if math.isinf(x) or math.isnan(x) or not x:
return '{:.0f}'.format(x)
p = max(p, 1)
sig, exp = '{:.{}e}'.format(x, p-1).split('e')
if -4 <= int(exp) < p:
return strip_zero_dot('{:.{}f}'.format(x, p-1-int(exp)))
else:
return strip_zero_dot(sig) + 'e' + exp
----------
components: +Documentation
resolution: -> fixed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7051>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com