When dumping (ruamel.yaml, PyYAML) the dict data = {'abc': 'def'}
as YAML (with default_flow_style=False
) in Python 2.7 you will get:
abc: def
which is fine. However if you make all strings unicode (by u
prefixing or by using from __future__ import unicode_literals
) this gets dumped as:
!!python/unicode 'abc': !!python/unicode 'def'
How can I dump all strings (unicode prefixed or not) without tag, without reverting to using safe_dump()
? Adding allow_unicode=True
doesn't do the trick.
Complete example that generates the unwanted tags:
from __future__ import unicode_literals
import sys
import ruamel.yaml
data = {'abc': 'def'}
ruamel.yaml.safe_dump(data, sys.stdout, allow_unicode=True, default_flow_style=False)