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

Requirements

PyYAML requires Python 2.7 or Python 3.5+.

Download and Installation

The current stable release of PyYAML: 5.3.

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

5.3.1 (2020-03-18)

5.3 (2020-01-06)

5.2 (2019-12-02)

5.1 (2019-03-13)

3.13 (2018-07-05)

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)

Copyright (c) 2017-2019 Ingy döt Net Copyright (c) 2006-2016 Kirill Simonov

The PyYAML module was written by Kirill Simonov. It is now maintained by the YAML community.

PyYAML is released under the MIT license.