Section » element

element(name) → element or None
element(name, options) → element or None

Retrieve a single element of any allowed type from the section by its name. Optionally specify whether it's optional or mandatory for the element to be present in the eno document (by default it's optional).

enotitle: Artfest 2018
tags:
- art
- code

# content
> ...
python>>> document = enopy.parse(input)

>>> document.element('title')
<class Field name="title" value="Artfest 2018">
>>> document.element('tags')
<class List name="tags" items=2>
>>> document.element('content')
<class Section name="content" items=14>
>>> document.element('fantasy')
None
>>> document.element('fantasy', enforce_element=True)
ValidationError: ...
>>> document.element('fantasy', required=True)
ValidationError: ...

Parameters

name

The name of the element to fetch from the section as a string.

options

enforce_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 (e.g. List, Field, etc.) or None.