def requiredAttribute(requiredAttributeName):
class RequiredAttribute(attribute):<EOL><INDENT>def get(self):<EOL><INDENT>if requiredAttributeName not in self.__dict__:<EOL><INDENT>raise AttributeError(<EOL>('<STR_LIT>'<EOL>'<STR_LIT>' % (<EOL>requiredAttributeName, self)))<EOL><DEDENT>return self.__dict__[requiredAttributeName]<EOL><DEDENT>def set(self, value):<EOL><INDENT>self.__dict__[requiredAttributeName] = value<EOL><DEDENT><DEDENT>return RequiredAttribute<EOL>
Utility for defining attributes on base classes/mixins which require their
values to be supplied by their derived classes.  C{None} is a common, but
almost never suitable default value for these kinds of attributes, as it
may cause operations in the derived class to fail silently in peculiar
ways.  If a C{requiredAttribute} is accessed before having its value
changed, a C{AttributeError} will be raised with a helpful error message.

@param requiredAttributeName: The name of the required attribute.
@type requiredAttributeName: C{str}

Example:
    >>> from epsilon.descriptor import requiredAttribute
    ...
    >>> class FooTestMixin:
    ...  expectedResult = requiredAttribute('expectedResult')
    ...
    >>> class BrokenFooTestCase(TestCase, FooTestMixin):
    ...  pass
    ...
    >>> brokenFoo = BrokenFooTestCase()
    >>> print brokenFoo.expectedResult
    Traceback (most recent call last):
        ...
    AttributeError: Required attribute 'expectedResult' has not been
                    changed from its default value on '<BrokenFooTestCase
                    instance>'.
    ...
    >>> class WorkingFooTestCase(TestCase, FooTestMixin):
    ...  expectedResult = 7
    ...
    >>> workingFoo = WorkingFooTestCase()
    >>> print workingFoo.expectedResult
    ... 7
    >>>