Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiddyspence/43af0e9140168015bc4fa4b3f0138968 to your computer and use it in GitHub Desktop.
Save fiddyspence/43af0e9140168015bc4fa4b3f0138968 to your computer and use it in GitHub Desktop.
danger will yamlson, danger
$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::load_file 'test.yaml'
=> {"foo"=>"bar"}
irb(main):003:0> ^D
$ python
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import 'yaml'
File "<stdin>", line 1
import 'yaml'
^
SyntaxError: invalid syntax
>>> import yaml
>>> with open("test.yaml", 'r') as stream:
... try:
... print(yaml.load(stream))
... except yaml.YAMLError as exc:
... print(exc)
...
expected a single document in the stream
in "test.yaml", line 2, column 1
but found another document
in "test.yaml", line 3, column 1
>>>
$ cat test.yaml
---
foo: bar
---
foo: baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment