Skip to main content

Class to create dynamic objects.

Project description

Class to create dynamic objects.

Installation

Install through pip.

$ pip install dynamic

or get from source

$ git clone https://github.com/gravmatt/py-dynamic.git
$ cd py-dynamic
$ python setup.py install

Import module

Import the module into your python project.

from dynamic import Dynamic

Usage

Create object when you need them.

me = Dynamic()
me.name = 'Rene'
me.username = 'gravmatt'

print '%s (%s)' % (me.name, me.username)

# Rene (gravmatt)

Explicit Mode

By default the explicit is ON.

That means if you try to get a value that doesn’t exists, a AttributeError get raised.

me = Dynamic()
me.name = 'Rene'

print me.age # age does not exist

# AttributeError: Property 'age' not found

You can turn the explicit mode off, by:

me = Dynamic(explicit=False)
me.name = 'Rene'

print 'My age:', me.age
# My age: None

Now when you try to access a property that doesn’t exists, None get returned.

Licence

The MIT License (MIT)

Copyright (c) 2016 René Tanczos

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

dynamic-0.1.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file dynamic-0.1.1.tar.gz.

File metadata

  • Download URL: dynamic-0.1.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dynamic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 385a601076538274a42060b1d650fe662f7aa5b15ae95bbdd4ac6d2c49302dba
MD5 27e69deed16c556320f893c8a0f02949
BLAKE2b-256 cb7323ee6a1b99c1a3dfc5e3f66b5f3921bc1707a04509911d770f8f67565eb8

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