PyYAML

PyYAML is a YAML parser and emitter for Python.

PyYAML is now maintained at https://github.org/yaml/pyyaml. This page is left for historical purposes.

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

Requirements

PyYAML requires Python 2.7 or Python 3.4+.

Download and Installation

The current stable release of PyYAML: 3.12.

Download links:

Unpack the archive and install the package by executing

$ python setup.py install

If you want to use LibYAML bindings, you need to download and install LibYAML. Then you may install the bindings by executing

$ python setup.py --with-libyaml install

The source distribution includes a comprehensive test suite. To run the tests, type

$ python setup.py test

Documentation

Quick example (see documentation for loading multiple documents):

>>> import yaml

>>> print yaml.load("""
... name: Vorlin Laruknuzum
... sex: Male
... class: Priest
... title: Acolyte
... hp: [32, 71]
... sp: [1, 13]
... gold: 423
... inventory:
... - a Holy Book of Prayers (Words of Wisdom)
... - an Azure Potion of Cure Light Wounds
... - a Silver Wand of Wonder
... """)

{'name': 'Vorlin Laruknuzum', 'gold': 423, 'title': 'Acolyte', 'hp': [32, 71],
'sp': [1, 13], 'sex': 'Male', 'inventory': ['a Holy Book of Prayers (Words of Wisdom)',
'an Azure Potion of Cure Light Wounds', 'a Siver Wand of Wonder'], 'class': 'Priest'}

>>> print yaml.dump({'name': "The Cloak 'Colluin'", 'depth': 5, 'rarity': 45,
... 'weight': 10, 'cost': 50000, 'flags': ['INT', 'WIS', 'SPEED', 'STEALTH']})

name: The Cloak 'Colluin'
rarity: 45
flags: [INT, WIS, SPEED, STEALTH]
weight: 10
cost: 50000
depth: 5

For more details, please check PyYAML Documentation.

History

3.12 (2016-08-28)

3.11 (2014-03-26)

3.10 (2011-05-30)

3.09 (2009-08-31)

3.08 (2008-12-31)

3.07 (2008-12-29)

3.06 (2008-10-03)

3.05 (2007-05-13)

3.04 (2006-08-20)

3.03 (2006-06-19)

3.02 (2006-05-15)

3.01 (2006-05-07)

The PyYAML module is written by .

PyYAML is released under the MIT license.