core.check¶
Functions¶
is_empty ¶
Check whether the input is empty.
Determines if the input value is considered empty based on various criteria
- Empty strings (after stripping whitespace)
- Collections with zero length (lists, dicts, tuples)
- None values
- False boolean values
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | Any | The value to check for emptiness. Can be any type. | required |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | True if the input is considered empty, False otherwise. |
Examples:
>>> is_empty("")
True
>>> is_empty(" ")
True
>>> is_empty([])
True
>>> is_empty({})
True
>>> is_empty(None)
True
>>> is_empty(False)
True
>>> is_empty("hello")
False
>>> is_empty([1, 2, 3])
False
Source code in pyadvtools/core/check.py
is_list_contain_list_contain_str ¶
Check if all nested lists contain only strings.
Verifies that the input is a list of lists, where each inner list contains only string elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xxx | list | List of lists to check for string-only content. | required |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | True if all nested lists contain only strings, False otherwise. |
Examples:
>>> is_list_contain_list_contain_str([["a", "b"], ["c", "d"]])
True
>>> is_list_contain_list_contain_str([["a", "b"], ["c", 123]])
False
>>> is_list_contain_list_contain_str([])
True
Source code in pyadvtools/core/check.py
is_list_contain_str ¶
Check if all elements in the list are strings.
Verifies that every element in the provided list is of string type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xx | list | List of elements to check for string type. | required |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | True if all elements are strings, False otherwise. |
Examples:
>>> is_list_contain_str(["hello", "world", "test"])
True
>>> is_list_contain_str(["hello", 123, "world"])
False
>>> is_list_contain_str([])
True