If safe_dump (i.e. dump
with Dumper=SafeDumper
) is used, then calling yaml.add_representer
has no effect. In such case it is necessary to call add_representer
method explicitly on SafeRepresenter
class:
yaml.representer.SafeRepresenter.add_representer(
OrderedDict, ordered_dict_representer
)