module documentation

Contains routines for casting to and from types. Generally useful for simple data marshalling to and from text

Exception CastException If casts fail, throw this exception
Function to Casts an object to a type
Function to_any Casts and object to any of the given types.
def to(x: Any, atype: type) -> type:

Casts an object to a type

Parameters
x:Anyany Object to cast
atype:typetype type to cast to
Returns
typex casted to atype, throws CastException on failure.
def to_any(x: Any, types: Iterable[type]) -> Any:

Casts and object to any of the given types.

Parameters
x:AnyAny Object to cast
types:Iterable[type]Iterable[type] Iterable (e.g., list) of the types to attempt to cast to. Once one cast succeeds, the others are not attempted.
Returns
Anyx casted to the first type that succeeds. Throws CastException on failure.