Skip to main content

Python library for AXON

Project description

pyaxon is an MIT Licensed python library for AXON. AXON is eXtended Object Notation. It’s a simple text based format for interchanging objects, documents and data. It tries to combine the best of JSON, XML and YAML.


pyaxon runs under Python 2.7/3.3/3.4.

It can be installed via pip:

pip install pyaxon

It can be installed from sources:

python install

Quick start

First import axon module:

>>> import axon

Load and dump lists, dicts, tuples:

>>> from decimal import Decimal
>>> from datetime import datetime, time, date
>>> text = axon.dumps([['abc абв', 1, 3.14, True],
[, Decimal('3.14')]])
>>> print(text)
["abc абв" 1 3.14 true]
[2015-05-12T13:08:37.078189 3.14D]

>>> vals = [{'id':1, 'nickname':'nick', 'time':time(12, 31, 34), 'text':'hello!'},
{'id':2, 'nickname':'mark', 'time':time(12, 32, 3), 'text':'hi!'}]
>>> text = axon.dumps(vals)
>>> print(text)
{id:1 nickname:"nick" text:"hello!" time:12:31:34}
{id:2 nickname:"mark" text:"hi!" time:12:32:03}
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
{ id: 1
  nickname: "nick"
  text: "hello!"
  time: 12:31:34}
{ id: 2
  nickname: "mark"
  text: "hi!"
  time: 12:32:03}
>>> vals == axon.loads(text)

>>> vals = [[{'a':1, 'b':2, 'c':3}, {'a':[1,2,3], 'b':(1,2,3), 'c':[]}]]
>>> text = axon.dumps(vals)
>>> print(text)
[{a:1 b:2 c:3} {a:[1 2 3] b:(1 2 3) c:[]}]
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
[ { a: 1
    b: 2
    c: 3}
  { a: [1 2 3]
    b: (1 2 3)
    c: []}]
>>> vals == axon.loads(text)

Dump, load objects in “safe” mode:

>>> vals = axon.loads('person{name:"nick" age:32 email:""}')
>>> print(type(vals[0]))
<class 'axon._objects.Mapping'>
>>> print(vals[0])
mapping('person', {'email': '', 'age': 32, 'name': 'nick'})

>>> text = axon.dumps(vals)
>>> print(text)
person{age:32 email:"" name:"nick"}
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
  age: 32
  email: ""
  name: "nick"
>>> text = axon.dumps(vals, pretty=1, braces=1)
>>> print(text)
person {
  age: 32
  email: ""
  name: "nick"}

Dump, load objects in unsafe mode:

lass Person:
    def __init__(self, name, age, email): = name
        self.age = age = email

    def __str__(self):
        return "Person(name=%r, age=%r, email=%r)" % (, self.age,

def reduce_Person(p):
    return axon.node('person',
                      axon.attribute('age', p.age),

def factory_Person(p):
    a1, a2, a3 = p
    return Person(p[0].value, p[1].value, p[2].value)

>>> p = Person('nick', 32, '')
>>> text = axon.dumps([p])
>>> print(text)
person{age:32 email:"" name:"nick"}
>>> val = axon.loads(text, mode='strict')[0]
>>> print(val)
Person(name='nick', age=32, email='')
>>> print(, val.age==p.age,
True True True


  1. Provide simple API for loading and dumping of objects in textual AXON format.
  2. Provide safe loading and dumping by default.
  3. Provide unsafe loading and dumping of objects on the base of registration of factory/reduce callables.
  4. Provide a way for fully controlled by application/framework/library unsafe loading and dumping.
  5. It’s sufficiently fast so as to be useful.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyaxon, version 0.7
Filename, size File type Python version Upload date Hashes
Filename, size pyaxon-0.7-cp27-none-macosx_10_6_intel.whl (639.9 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyaxon-0.7-cp33-cp33m-macosx_10_6_intel.whl (647.2 kB) File type Wheel Python version cp33 Upload date Hashes View hashes
Filename, size pyaxon-0.7-cp34-cp34m-macosx_10_6_intel.whl (648.5 kB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size (429.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page