Skip to main content

Access dict values as attributes (works recursively)

Project description

Access dict values as attributes (works recursively)

<https://github.com/makinacorpus/easydict>

USAGE

>>> from easydict import EasyDict
>>> d = EasyDict({'foo':3, 'bar':{'x':1, 'y':2}})
>>> d.foo
3
>>> d.bar.x
1

Very useful when exploiting parsed JSON content !

>>> from easydict import EasyDict
>>> from simplejson import loads
>>> j = """{
"Buffer": 12,
"List1": [
    {"type" : "point", "coordinates" : [100.1,54.9] },
    {"type" : "point", "coordinates" : [109.4,65.1] },
    {"type" : "point", "coordinates" : [115.2,80.2] },
    {"type" : "point", "coordinates" : [150.9,97.8] }
]
}"""
>>> d = EasyDict(loads(j))
>>> d.Buffer
12
>>> d.List1[0].coordinates[1]
54.9

LICENSE

  • Lesser GNU Public License

CHANGELOG

1.0

  • Initial version. Does what I need.

AUTHORS

Project details


Download files

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

Source Distribution

easydict-1.0.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file easydict-1.0.tar.gz.

File metadata

  • Download URL: easydict-1.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for easydict-1.0.tar.gz
Algorithm Hash digest
SHA256 4a4afc66938c3124ebbde535a13334ac783ca14d93315e5730e9811a5cf45ac7
MD5 64893c339cc305cad78929b336ac35db
BLAKE2b-256 595146d851e44fa5ef399f152ca2675c95f53d52ec7066a087f2c81a072cbbca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page