Formatting#

Module for formatting type and functions.

as_type(value, types=[<class 'int'>, <class 'float'>])[source]#

Tries to convert value to given data types.

Arguments

valueobject

The value to be converted.

typeslist of types

The list of types to try to convert the value to.

Returns

valueobject

The value converted to the types if possible.

ensure(value, dtype)[source]#

Ensure values have a specified type but allowing for None values.

Arguments

valueobject

The value to copy

dtypeclass

The class type of the value to be copied.

Returns

valueobject

The value with the requested type.