wiki:PyYAML

Version 6 (modified by xi, 9 years ago) (diff)

--

PyYAML

PyYAML is a YAML parser and emitter for Python.

Overview

 YAML is a data serialization format designed for human readability and interaction with scripting languages.

PyYAML is a YAML parser and emitter for the Python programming language.

PyYAML features

  • a complete  YAML 1.1 parser. In particular, PyYAML can parse all examples from the specification. The parsing algorithm is simple enough to be ported to C or other language.
  • Unicode support including UTF-8/UTF-16 input and \u escape sequences.
  • event-based parser and emitter API (like SAX).
  • high-level API for serializing and deserializing native Python objects (like DOM or pickle).
  • support for all types from the  YAML types repository. A simple extension API is provided.
  • relatively meaningful error messages.

Note that PyYAML is still young and may have some bugs. Furthermore, PyYAML is written in Python and is slow comparing to C based parsers.

Requirements

PyYAML requires Python 2.3 or higher.

Download and Installation

You may check out PyYAML code from the Subversion repository  http://svn.pyyaml.org/pyyaml/trunk

$ svn checkout http://svn.pyyaml.org/pyyaml/trunk pyyaml-trunk

Install it by running

$ python setup.py install

Documentation

Quick example:

>>> from yaml import *
>>> print load("""
... - foo
... - bar
... - baz
... """)
['foo', 'bar', 'baz']
>>> print dump(['foo', 'bar', 'baz'])
- foo
- bar
- baz

For more details, please check PyYAML Documentation.

Development and bug reports

You may check out the PyYAML source code from  PyYAML SVN repository.

If you find a bug in PyYAML, please file a bug report. You may review open bugs through the list of open tickets.

You may discuss PyYAML at  the YAML-core mailing list.

Author and copyright

The PyYAML module is written by Kirill Simonov.

PyYAML is released under the MIT license.