Skip to main content

An object wrapper for dict that allows for using object type notation with dictionaries.

Project description

OBJDICT

An object wrapper for dict that allows for using object type notation with dictionaries.

Installation

pip install objdict-hephhay

Description

An object style implementation for dict that allows for using object type dot(.) notation with dictionaries.

All dict operations such as .pop(), .items(), .contains() etc' will also work with ObjDict

Example

from objdict_hephhay import ObjDict
object = ObjDict(<dict>)

object.<dict key>

usage

Parameters

dict : int Dictionary to convert

depth : int Second number to add = 0 if you want only a single level of conversion

Returns

objdict.ObjDict An instance of ObjDict

Examples

>>>  obj = ObjDict(foo = 1, bar = 2)
<ObjDict : {"foo" : 1, "bar" : 2}>
>>> dictionary = {"foo" : 1, "bar" : 2}
>>> obj1 = ObjDict(dictionary)
>>> obj1.foo
1
>>> dictionary_2 = {"foo" : 1, "bar" : 2, "baz" : {"alice" : 3, "bob" : {"steph" : 5}}}
>>> obj2 = ObjDict(dictionary_2, depth = 1)
>>> obj2.bar
2
>>> obj2.baz
<ObjDict : {'alice': 3, 'bob': {'steph': 5}}>

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

objdict_hephhay-0.1.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

objdict_hephhay-0.1.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

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