I'm trying to understand the use of
document = """
print yaml.dump(yaml.load(document), default_flow_style=False)
AttributeError: 'module' object has no attribute 'dump'
You called your example
yaml.py and as such your test program is imported with the
import yaml statement, and it doesn't have a
Just rename your
yaml.py to something like
You should also use:
import sys yaml.dump(yaml.load(document, sys.stdout, default_flow_style=False)
as not providing a stream as the second parameter to
dump() causes the output to first be written to a
StringIO() object, then to be retrieved by
.getvalue() on that object, and then written out to
sys.stdout. It is faster to do the latter directly.