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 a list of homogeneous basic types.
The type of the elements in the list is determined via the first element. Successive elements are cast to that type.
| PARAMETER | DESCRIPTION |
|---|---|
s
|
String representation of a list.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list
|
List of homogeneous basic types. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If string does not represent a list. |
TypeError
|
If string does not represent a list of homogeneous basic types. |