Re: [PyYAML] problems with nested mappings
Kirill Simonov <xi-RCSp1WnSyaseIZ0/[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
A YAML mapping is constructed lazily, so `construct_mapping()` may
return an empty dictionary to be populated later. To get a complete
dictionary, use `loader.construct_mapping(node, deep=True)`.
On 10/01/2012 03:25 PM, Manlio Perillo wrote:
> -----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
> _______________________________________________
> Yaml-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/yaml-core
>
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev