Odd Behavior with Standard Loader and Scientific Notation

Issue #2 new
Eric Cousieau
created an issue

I'm noticing some odd behavior with PyYaml v3.10 (from Ubuntu 12.04 repos) regarding scientific notation, and could not find anything about it in the old PyYAML issue tracker.

I expected the following string to be converted to floats, but not all of them get there:

In [47]: yaml.load('[350e1, 350e-1, 350.e1, 350.e-1, 1e2, 1.e-2, 1e12, 1.e-12, 1e-12]')
Out[47]: ['350e1', '350e-1', '350.e1', 35.0, '1e2', 0.01, '1e12', 1e-12, '1e-12']

In [48]: print yaml.__version__

I parsed the same string with yaml-cpp and SnakeYaml (default loaders / parsers) and they produced all floats.

Comments (2)

  1. Log in to comment