Re: PyYAML yaml.load() appears to be alphabetizing input

"Erich Zigler" <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
On Sat, Apr 26, 2008 at 3:05 AM, Alexey Zakhlestin <[email protected]> wrote:

> If that application requires specific order of dictionary it is not
>  yaml-compliant.
>
>  in yaml, ordered structure is "sequence". So, if order is important,
>  you should put "key-value" pairs into the sequence. something like
>  this:
>
>  ---
>  - hellanzb-pass: changeme
>
> - hellanzb-host: localhost
>
>  - newzbin-interval: 8
>  - tvrage-interval: 300
>  ...

Thanks for all the help. I have done research all morning and have
found this page which describes my issue well:

http://pyyaml.org/ticket/29

However I am having some issues with the code example given:

>>> import yaml
>>> def omap_constructor(loader, node):
...     return loader.construct_pairs(node)
...
>>> yaml.add_constructor(u'!omap', omap_constructor)
>>> yaml.load('!omap { C: 1, B: 2, A: 1 }')
[('C', 1), ('B', 2), ('A', 1)]

How can I use this constructor but have it load the yaml from a file?

Thanks,

Erich

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
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.