Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A library for mapping dictionaries to Python objects

Project Description

Sample usage

With dicty you can easily describe your data model and then use it to encode/decode JSON objects. It supports data validataion, optional parameters, default values, nested objects and so on.

import dicty

class MyDoc(dicty.DictObject):
    prop1 = dicty.StringField()
    prop2 = dicty.IntegerField()

# Regular constructor
doc = MyDoc(prop1='foo', prop2=123)
print doc.prop1     # you can access values as attributes
print doc['prop2']  # as well as dictionary items

print json.dumps(doc)
print json.dumps(doc.jsonify()) # Jsonify will clean and validate output data

# Create instance from dictionary
doc = MyDoc.fromjson({'prop1': 'foo', 'prop2': 123})

# would raise dicty.FieldError here
doc = MyDoc.fromjson({'prop1': 123, 'prop2': 123})

Nested Objects

import dicty

class Foo(dicty.DictObject):
    class Bar(dicty.DictObject):
        prop = dicty.StringField()

    bar = dicty.TypedObjectField(Bar)

obj = Foo() = 123
print obj # {'bar': {'prop': 123}}

Release History

History Node


This version
History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(3.9 kB) Copy SHA256 Hash SHA256
Source None Jun 7, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting