Coercion

datatype.coercion

datatype.coercion.coerce_value(datatype, value)

Attempt to coerce value to requested datatype.

Example:
>>> coerce_value("int", "5")
5

If coercion is not possible, the incoercible portion is left changed.

Example:
>>> coerce_value(['int'], ['1', '2', 'c'])
[1, 2, 'c']

Project Versions

Table Of Contents

Previous topic

Validation

This Page