5.1.1.10.1. AttributeDictionaryInterface

class CodeReview.Tools.AttributeDictionaryInterface.AttributeDictionaryInterface[source]

Bases: CodeReview.Tools.AttributeDictionaryInterface.ReadOnlyAttributeDictionaryInterface

This class implements an attribute and dictionary interface.

Example:

attribute_dictionary = AttributeDictionaryInterface()

attribute_dictionary['a'] = 1
print attribute_dictionary['a']

attribute_dictionary.b = 2
print attribute_dictionary.b

'a' in attribute_dictionary
list(attribute_dictionary)
# will return [1, 2]
class CodeReview.Tools.AttributeDictionaryInterface.AttributeDictionaryInterfaceDescriptor[source]

Bases: CodeReview.Tools.AttributeDictionaryInterface.AttributeDictionaryInterface

This class implements an attribute and dictionary interface using Descriptor.

Example:

class DescriptorExample:
    def __init__(self, value):
        self.value = value
    def get(self):
        return self.value
    def set(self, value):
        self.value = value

attribute_dictionary = AttributeDictionaryInterfaceDescriptor()
attribute_dictionary._dictionary['attribute1'] = DescriptorExample(1)

attribute_dictionary['attribute1'] = 2
print attribute_dictionary['attribute1']

attribute_dictionary.attribute1 = 3
print attribute_dictionary.attribute1
_get_descriptor(name)[source]
class CodeReview.Tools.AttributeDictionaryInterface.ExtendedDictionaryInterface[source]

Bases: dict

This class implements an extended dictionary interface.

Example:

extended_dictionary = ExtendedDictionaryInterface()

extended_dictionary['key1'] = 1
print extended_dictionary['key1']
print extended_dictionary.key1

# Unusal use case
extended_dictionary.key2 = 1
print extended_dictionary.key2
# print extended_dictionary['key2'] # Not Implemented
class CodeReview.Tools.AttributeDictionaryInterface.ReadOnlyAttributeDictionaryInterface[source]

Bases: object

This class implements a read-only attribute and dictionary interface.

Example:

attribute_dictionary = ReadOnlyAttributeDictionaryInterface()

attribute_dictionary._dictionary['a'] = 1
attribute_dictionary._dictionary['b'] = 2

print attribute_dictionary['a']
print attribute_dictionary.b

'a' in attribute_dictionary
list(attribute_dictionary)
# will return [1, 2]
items()[source]
keys()[source]
values()[source]