Skip to main content

A simple package to create data structures with defaultsob

Project description

https://img.shields.io/travis/honewatson/defaultsob.svg https://img.shields.io/pypi/v/defaultsob.svg

A simple package to create data structures with defaults and strict limitations of attributes/properties.

Features

class User(Defaults):
    __slots__ = [
       "name",
       "description",
       "an_attribte_with_no_default"
   ]
   """
   usef will use the 'name' attribute
   if the description attribute is not
   set at the time of object creation
   """
   description = usef('name')

user = User(name='Billy')
"""
.to_dict_clean method returns a
dictionary of attributes with values
"""
print(user.to_dict_clean())
{
   "name": "Billy",
   "description": "Billy"
}

user.description = "Something Else"
user.an_attribute_with_no_default = "Another"
print(user.to_dict_clean())
{
   "name": "Billy",
   "description": "Something Else"
   "an_attribute_with_no_default": "Another"
}


user2 = User(name="Billy", description="The Kid")
print(user2.to_dict_clean())
{
   "name": "Billy",
   "description": "The Kid"
}

History

0.1.0 (2015-01-11)

  • First release on PyPI.

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

defaultsob-0.3.0.tar.gz (13.2 kB view details)

Uploaded Source

File details

Details for the file defaultsob-0.3.0.tar.gz.

File metadata

  • Download URL: defaultsob-0.3.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for defaultsob-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cf5a397f1c37639404a24de8323a1165781c6b5d9fd5f6eb94219e4d56f80b63
MD5 0a967320dade27903aec9b8f1aaa9976
BLAKE2b-256 eca3dd2e8119d691019f7851e52fd2f160eea55e21c5918f0413da6858aa0aad

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