From: Clark C. E. <cc...@cl...> - 2003-10-27 01:41:22
|
I was asked a question off-list about how YAML 'escaping' worked, especially in the context of Python. I guess the best way to answer is with running code... --------------------------------------------- #!/usr/local/bin/python a = { "p1": {"- foo":"goo","- bar":"baz"}, "p2": [ "foo: goo", "bar: baz"], "p3": [ {"foo":"goo"},{"bar":"baz"}] } import syck b = syck.load("""\ --- { p1: {'- foo': goo, '- bar': baz}, p2: ['foo: goo', 'bar: baz'] , p3: [{foo: goo}, {bar: baz}] } """) c = syck.load("""\ --- p1: {'- foo': goo, '- bar': baz} p2: ['foo: goo', 'bar: baz'] p3: [{foo: goo}, {bar: baz}] """) d = syck.load("""\ --- p1: '- foo': goo '- bar': baz p2: - 'foo: goo' - 'bar: baz' p3: - foo: goo - bar: baz """) print "a == b", str(a) == str(b) print "a == c", str(a) == str(c) print "a == d", str(a) == str(d) ----- End forwarded message ----- |