confusing docs for plistlib - how to use 'dump()'

Hi there - This regards the page for plistlib: https://docs.python.org/dev/library/plistlib.html#plistlib.dumps <https://docs.python.org/dev/library/plistlib.html#plistlib.dumps> I ran in to this problem described here: http://technology.siprep.org/how-to-read-from-and-write-to-plist-files-using... <http://technology.siprep.org/how-to-read-from-and-write-to-plist-files-using...> It’s just not clear in the docs how to use ‘dump’ - and the only way I could get a plist to be created is to use the deprecated plistlib.writePlist function. Does it have to be imported from some other module? Mark

Hi, It is stated in the docs that fp parameter in plistlib.dump is a writable binary file object, which can be created by calling open() . file object and how to create it are described here: https://docs.python.org/3/glossary.html#term-file-object Perhaps an improvement to the docs is to provide such link? Here's an example demonstrating how to use plistlib.dump: import plistlib p = {"name": "James Bond", "code": 0.07} plistlib.dump(p, open("./output.xml", "wb+")) HTH On Dec 6, 2016 5:49 AM, "Mark" <mark@markjharris.net> wrote:
Hi there -
This regards the page for plistlib:
https://docs.python.org/dev/library/plistlib.html#plistlib.dumps
I ran in to this problem described here:
http://technology.siprep.org/how-to-read-from-and-write-to-p list-files-using-python/
It’s just not clear in the docs how to use ‘dump’ - and the only way I could get a plist to be created is to use the deprecated plistlib.writePlist function.
Does it have to be imported from some other module?
Mark
_______________________________________________ docs mailing list docs@python.org https://mail.python.org/mailman/listinfo/docs
participants (2)
-
Mariatta Wijaya
-
Mark