def add_fields(store_name, field_names):
    """
    A class-decorator that creates layout managers with a set of named
    fields.
    """
    def decorate(cls):
        def _add(index, name):
            def _set_dir(self, value): getattr(self, store_name)[index] = value
            def _get_dir(self): return getattr(self, store_name)[index]
            setattr(cls, name, property(_get_dir, _set_dir))

        for index, field_name in enumerate(field_names):
            _add(index, field_name)

        return cls

    return decorate
def add_fields ( store_name , field_names ) : def decorate ( cls ) : def _add ( index , name ) : def _set_dir ( self , value ) : getattr ( self , store_name ) [ index ] = value def _get_dir ( self ) : return getattr ( self , store_name ) [ index ] setattr ( cls , name , property ( _get_dir , _set_dir ) ) for index , field_name in enumerate ( field_names ) : _add ( index , field_name ) return cls return decorate
A class-decorator that creates layout managers with a set of named
    fields.