sanitize_list_index
FunctionPrivateSource
index: int = sanitize_list_index(index: Any)
Try to ensure index
to be a int
. If failed, raise ValueError
.
Arguments
Requires
Argument | Type | Required | |
---|---|---|---|
index | Any | The value to be sanitized. |
Returns
Argument | Type | |
---|---|---|
index | int | The sanitized index . |
Examples
Sanitize an index
- Codes
- Results
sanitize_an_index.py
from dash_json_grid.mixins import sanitize_list_index
print(repr(1), repr(sanitize_list_index(1)))
print(repr("10"), repr(sanitize_list_index("10")))
1 1
'10' 10