MCPcopy Create free account
hub / github.com/astanin/python-tabulate / _afterpoint

Function _afterpoint

tabulate/__init__.py:1038–1064  ·  view source on GitHub ↗

Symbols after a decimal point, -1 if the string lacks the decimal point. >>> _afterpoint("123.45") 2 >>> _afterpoint("1001") -1 >>> _afterpoint("eggs") -1 >>> _afterpoint("123e45") 2 >>> _afterpoint("123,456.78") 2

(string)

Source from the content-addressed store, hash-verified

1036
1037
1038def _afterpoint(string):
1039 """Symbols after a decimal point, -1 if the string lacks the decimal point.
1040
1041 >>> _afterpoint("123.45")
1042 2
1043 >>> _afterpoint("1001")
1044 -1
1045 >>> _afterpoint("eggs")
1046 -1
1047 >>> _afterpoint("123e45")
1048 2
1049 >>> _afterpoint("123,456.78")
1050 2
1051
1052 """
1053 if _isnumber(string) or _isnumber_with_thousands_separator(string):
1054 if _isint(string):
1055 return -1
1056 else:
1057 pos = string.rfind(".")
1058 pos = string.lower().rfind("e") if pos < 0 else pos
1059 if pos >= 0:
1060 return len(string) - pos - 1
1061 else:
1062 return -1 # no point
1063 else:
1064 return -1 # not a number
1065
1066
1067def _padleft(width, s):

Callers 1

Calls 3

_isnumberFunction · 0.85
_isintFunction · 0.85

Tested by

no test coverage detected