Python 3: Plist as OrderedDict

Stephen Hansen apt.shansen at gmail.com
Tue Feb 9 12:06:42 EST 2010


On Tue, Feb 9, 2010 at 8:07 AM, Gnarlodious <gnarlodious at gmail.com> wrote:

> To extract the list I am saying this:
>
> ordered=plistlib.readPlist(path)
> print(list(ordered))  # only a list of keys
> print(ordered[list(ordered)[0]])
>
> However this seems too laborious. is there an easier way?
>

I'm not familiar with plistlib or what you're trying to do-- it'd help if
you provided the output from those print's, as I don't have a plist on hand
which I can use to test it out and see what you're seeing.

But, is "ordered.keys()" or "ordered.items()" what you're trying to get? Or,
ordered[ordered.keys()[0]] to get the first one? Or "for key in ordered:
print(ordered[key])" which will get the keys in order and print the values
according to that order?

Basically, I'm not sure what you're actually trying to do.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100209/5ef1cc2b/attachment.html>


More information about the Python-list mailing list