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

Function _isnumber_with_thousands_separator

tabulate/__init__.py:862–892  ·  view source on GitHub ↗

>>> _isnumber_with_thousands_separator(".") False >>> _isnumber_with_thousands_separator("1") True >>> _isnumber_with_thousands_separator("1.") True >>> _isnumber_with_thousands_separator(".1") True >>> _isnumber_with_thousands_separator("1000") False >>>

(string)

Source from the content-addressed store, hash-verified

860
861
862def _isnumber_with_thousands_separator(string):
863 """
864 >>> _isnumber_with_thousands_separator(".")
865 False
866 >>> _isnumber_with_thousands_separator("1")
867 True
868 >>> _isnumber_with_thousands_separator("1.")
869 True
870 >>> _isnumber_with_thousands_separator(".1")
871 True
872 >>> _isnumber_with_thousands_separator("1000")
873 False
874 >>> _isnumber_with_thousands_separator("1,000")
875 True
876 >>> _isnumber_with_thousands_separator("1,0000")
877 False
878 >>> _isnumber_with_thousands_separator("1,000.1234")
879 True
880 >>> _isnumber_with_thousands_separator(b"1,000.1234")
881 True
882 >>> _isnumber_with_thousands_separator("+1,000.1234")
883 True
884 >>> _isnumber_with_thousands_separator("-1,000.1234")
885 True
886 """
887 try:
888 string = string.decode()
889 except (UnicodeDecodeError, AttributeError):
890 pass
891
892 return bool(re.match(_float_with_thousands_separators, string))
893
894
895def _isconvertible(conv, string):

Callers 2

_typeFunction · 0.85
_afterpointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected