Skip to content

Instantly share code, notes, and snippets.

@achalddave
Created October 7, 2016 16:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save achalddave/0fe5749a43ed7e14774f5ff28dda173f to your computer and use it in GitHub Desktop.

The default yaml library in lua does not handle YAML booleans correctly.

/tmp ~ th

  ______             __   |  Torch7
 /_  __/__  ________/ /   |  Scientific computing for Lua.
  / / / _ \/ __/ __/ _ \  |  Type ? for help
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch
                          |  http://torch.ch

th> yaml = require 'yaml'
                                                                      [0.0016s]
th> a = yaml.load('foo: True')
                                                                      [0.0001s]
th> b = yaml.load('foo: true')
                                                                      [0.0001s]
th> type(a.foo)
string
                                                                      [0.0000s]
th> type(b.foo)
boolean
                                                                      [0.0000s]
th> Do you really want to exit ([y]/n)? y

By comparison, python handles this just fine:

12:29:49 | trinity
/tmp ~ ipy
WARNING: IPython History requires SQLite, your history will not be saved
Python 2.7.4 (default, Apr 19 2013, 14:18:01)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import yaml

In [2]: a = yaml.load('foo: True')

In [3]: b = yaml.load('foo: true')

In [4]: type(a['foo'])
Out[4]: bool

In [5]: type(b['foo'])
Out[5]: bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment