Flexible collection that supports both dictionary and attribute style access.
Example usage:
>>> from chula import collection
>>> person = collection.Collection()
>>> person.name = 'Mr. Smith'
>>> person.age = 20
>>> person.timezone = 'PST'
>>>
>>> print person.age
20
>>> print person['timezone']
PST
>>> print person
{'timezone': 'PST', 'age': 20, 'name': 'Mr. Smith'}
Allow set via method
Parameters: |
|
---|
Copy the current object into the object passed
Parameters: | collection (chula.collection.Collection) – Object to be copied into |
---|---|
Return type: | chula.collection.Collection (filled copy) |
Allow list.remove() style attribute deletion
Parameters: | key (str) – Key/value pair to be removed |
---|
Collection with a configurable, but enforced number of attributes. This class is useful for situations where you you need to enforce every instance of the collection has the exact same structure.
Collection class with a pre-determined set of validkeys attributes
Purge privatekeys from the collection. This is useful when passing the collection along, without it’s private keys. This does actually delete the private keys, and thus acts on itself. If this isn’t what you want use copy.deepcopy().