Language Helpers

datatype.language

These small helper functions give a higher level interface for constructing complex datatype definitions, while maintaining portable datatypes.

datatype.language.choice(*choices)

Returns a ‘choice’ dictionary of the given choices.

Example:
>>> choice('str', 'int')
{'_type_': 'choice', 'choices': ['str', 'int']}
datatype.language.literal(value)

Returns a ‘literal’ dictionary.

Example:
>>> literal('foo')
{'_type_': 'literal', 'value': 'foo'}
datatype.language.named(name, value)

Returns a ‘named’ dictionary for naming the given ‘value’ datatype.

Example:
>>> named('person', {'first_name': 'str'})
{'_type_': 'named', 'name': 'person', 'value': {'first_name': 'str'}}
datatype.language.reference(name)

Returns a ‘reference’ dictionary for the given named type.

Example:
>>> reference('person')
{'_type_': 'reference', 'name': 'person'}

Project Versions

Table Of Contents

Previous topic

Coercion

This Page