Skip to content

Commit

Permalink
code made simpler by just making one call and one return point..
Browse files Browse the repository at this point in the history
  • Loading branch information
tenuki committed Oct 21, 2017
1 parent a696bbc commit d974259
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions texttable.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,14 @@ def _fmt_text(cls, x, **kw):
def _fmt_auto(cls, x, **kw):
"""auto formatting class-method."""
f = cls._to_float(x)

if abs(f) > 1e8:
return cls._fmt_exp(x, **kw)
if f - round(f) == 0:
return cls._fmt_int(x, **kw)
return cls._fmt_float(x, **kw)
fn = cls._fmt_exp
else:
if f - round(f) == 0:
fn = cls._fmt_int
else:
fn = cls._fmt_float
return fn(x, **kw)

def _str(self, i, x):
"""Handles string formatting of cell data
Expand Down

0 comments on commit d974259

Please sign in to comment.