autocast
Automatically detect the true Python type of a string and cast it to the correct type.
Based on https://github.com/cgreer/cgAutoCast/blob/master/cgAutoCast.py
Only used by Legacy configuration file parser.
Functions¶
autocast_value
¶
autocast_value(var: Any) -> Any
listify
¶
listify(s: str) -> list
Convert a string representation of a list into list of homogeneous basic types.
Type of elements in list is determined via first element. Successive elements are cast to that type.
Parameters:
s
-
String representation of a list.
TYPE:
str
Raises:
-
ValueError
-
If string does not represent a list.
-
TypeError
-
If string does not represent a list of homogeneous basic types.
Returns:
-
list
-
List of homogeneous basic types.