I found this related ticket on the PyYAML website ( http://pyyaml.org/ticket/91 ), it looks like bindings can be disabled using a custom line dump truck:
import yaml
class ExplicitDumper(yaml.SafeDumper):
"""
A dumper that will never emit aliases.
"""
def ignore_aliases(self, data):
return True
So, for example, the following outputs can be achieved using a standard dump truck and a new explicit dump truck:
>>> yaml.dump([1L, 1L])
"[&id001 !!python/long '1', *id001]\n"
>>> yaml.dump([1L, 1L], Dumper=ExplicitDumper)
'[1, 1]\n'
You can configure additional properties to ensure print privacy, etc. in a call yaml.dump(...).
source
share