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)
| 12 | |
| 13 | |
| 14 | def 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 | |
| 41 | def is_namedtuple(val): |
no outgoing calls
no test coverage detected