Function add_constructor
Synopsis
def add_constructor(tag, constructor, Loader=None)
Description
Add a constructor for the given tag. Constructor is a function that accepts a Loader instance and a node object and produces the corresponding Python object.
Mentioned in
- Documentation / Constructors, representers, resolvers
Source
Lines 339-351 in lib3/yaml/__init__.py.
def add_constructor(tag, constructor, Loader=None):
"""
Add a constructor for the given tag.
Constructor is a function that accepts a Loader instance
and a node object and produces the corresponding Python object.
"""
if Loader is None:
loader.Loader.add_constructor(tag, constructor)
loader.FullLoader.add_constructor(tag, constructor)
loader.UnsafeLoader.add_constructor(tag, constructor)
else:
Loader.add_constructor(tag, constructor)