[PyYAML] problems with nested mappings

Manlio Perillo <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

I don't understand why this script:

## BEGIN
from yaml import add_constructor, load, __version__


def test_constructor(loader, node):
    kwargs = loader.construct_mapping(node)
    print kwargs
    return kwargs
add_constructor(u'!test', test_constructor)


sample = """
bar: !test
  a: b
  foo:
    x: 1
"""


print __version__
print load(sample)
## END

Produce, as output:

  3.10
  {'a': 'b', 'foo': {}}
  {'bar': {'a': 'b', 'foo': {'x': 1}}}

I was expecting:

  3.10
  {'a': 'b', 'foo': {'x': 1}}
  {'bar': {'a': 'b', 'foo': {'x': 1}}}



Thanks  Manlio Perillo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlBp/FMACgkQscQJ24LbaUQeMgCfeZlbnyfmpUEr1ehKOJsd4hGU
SLIAn0UV/Lk8kWOGk+v2z4x3A2rh9c80
=Z87L
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.