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

Function _isint

tabulate/__init__.py:955–971  ·  view source on GitHub ↗

>>> _isint("123") True >>> _isint("123.45") False

(string, inttype=int)

Source from the content-addressed store, hash-verified

953
954
955def _isint(string, inttype=int):
956 """
957 >>> _isint("123")
958 True
959 >>> _isint("123.45")
960 False
961 """
962 return (
963 type(string) is inttype
964 or (
965 (hasattr(string, "is_integer") or hasattr(string, "__array__"))
966 and str(type(string)).startswith("<class 'numpy.int")
967 ) # numpy.int64 and similar
968 or (
969 isinstance(string, (bytes, str)) and _isconvertible(inttype, string)
970 ) # integer as string
971 )
972
973
974def _isbool(string):

Callers 2

_typeFunction · 0.85
_afterpointFunction · 0.85

Calls 1

_isconvertibleFunction · 0.85

Tested by

no test coverage detected