Field ยป value

value โ†’ value or None
value(options) โ†’ value or None
value(loader, options) โ†’ value or None

Retrieve the value of a Field, optionally passing it through a loader and/or supplying options.

enoflag color: beige
towel color:
|
python>>> document = enopy.parse(input)
>>> flag_color = document.element('flag color')
>>> towel_color = document.element('towel color')

>>> flag_color.value()
'beige'
>>> towel_color.value()
None
>>> flag_color.value(lambda name, value: value.replace('eig', 'lu'))
'blue'

Parameters

loader

A function returning the transformed/validated value or raising an error.The function is passed either name and value, in that order, or justvalue if your loader only takes a single argument.

options

enforce_value

Whether there must be a value or the field is allowed to be empty (default to False)

required

Alias for enforce_value (this exists on many methods and depending on context refers to either element or value)

Return value

The (optionally transformed/validated) value of this Field.