MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / is_primitive

Function is_primitive

functional/util.py:14–38  ·  view source on GitHub ↗

Checks if the passed value is a primitive type. >>> is_primitive(1) True >>> is_primitive("abc") True >>> is_primitive(True) True >>> is_primitive({}) False >>> is_primitive([]) False >>> is_primitive(set([])) :param val: value to check

(val)

Source from the content-addressed store, hash-verified

12
13
14def is_primitive(val):
15 """
16 Checks if the passed value is a primitive type.
17
18 >>> is_primitive(1)
19 True
20
21 >>> is_primitive("abc")
22 True
23
24 >>> is_primitive(True)
25 True
26
27 >>> is_primitive({})
28 False
29
30 >>> is_primitive([])
31 False
32
33 >>> is_primitive(set([]))
34
35 :param val: value to check
36 :return: True if value is a primitive, else False
37 """
38 return isinstance(val, (str, bool, float, complex, bytes, int))
39
40
41def is_namedtuple(val):

Callers 3

_wrapFunction · 0.90
_parse_argsMethod · 0.90
is_tabulatableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected