Skip to main content

License: MIT codecov Build Status Python 3.7

PyDapt

PyDapt coverts a dictionary into an object. It is similar to the OpenStruct of ruby.

Installation

Python Version Required >= 3
pip install pydapt

Usage

Converting a dictionary to Object

from pydapt.models import PyFlex

dictionary = {"test": 1, "test1": {"test2": 2}}
pyflex = PyFlex(dictionary)

print(pyflex.test) # 1
print(pyflex.test1.test2) # 2

Converting a dictionary to Object with kwargs

from pydapt.models import PyFlex

dictionary = {"test": 1, "test1": {"test2": 2}}
pyflex = PyFlex(dictionary, test3=3, test4=4)

print(pyflex.test) # 1
print(pyflex.test1.test2) # 2
print(pyflex.test3) # 3
print(pyflex.test4) # 4

Deleting an attribute

from pydapt.models import PyFlex

dictionary = {"test": 1, "test1": {"test2": 2}}
pyflex = PyFlex(dictionary)

print(pyflex.test) # 1
print(pyflex.test1.test2) # 2

pyflex.drop('test3') # None
pyflex.drop('test') # 1

print(pyflex.test) # AttributeError: 'PyFlex' object has no attribute 'test'

Download files

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

Source Distribution

pydapt-0.3.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file pydapt-0.3.tar.gz.

File metadata

  • Download URL: pydapt-0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for pydapt-0.3.tar.gz
Algorithm Hash digest
SHA256 29c7b02e9e769001a9361a20a1dba1979da03785b60f18b8edabb1390f8d8f1a
MD5 4f5acd12def378a56aa8330548314009
BLAKE2b-256 1e8e04c69030ee20ade747ee4a819896092070b8338dc9ded2d6a5e53d6fbaec

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3 This release

1 file

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page