Fieldset » element
element(name) → element or None
element(name, options) → element or None
Retrieve a single entry as Field
(instead of
its direct value) from the fieldset by its name.
Optionally specify whether it's optional or mandatory for the entry to be
present in the eno document (by default it's optional).
enoyears:
2007 = Year of the gooseberry
2010 = Year of the awesome beanstalk
2011 = Year of yearning
python>>> fieldset = enopy.parse(input).fieldset('years')
>>> fieldset.element('2010')
<class Field name="2010" value="Year of the awesome beanstalk">
>>> fieldset.element('2020')
None
>>> fieldset.element('2020', enforce_element=True)
ValidationError: ...
>>> fieldset.element('2020', required=True)
ValidationError: ...
Parameters
nameThe name of the entry to fetch from the fieldset as a string.
optionsenforce_element
Whether the element must be present in the document (True
or False
, defaults to False
)
required
Alias for enforce_element
(this exists on many methods and depending on context refers to either element or value)
Return value
An element (Field
) or None
.