def set_single_attribute(self, other, trigger_klass, property_name):
        """Used to set guard the setting of an attribute which is singular and can't be set twice"""

        if isinstance(other, trigger_klass):

            # Check property exists
            if not hasattr(self, property_name):
                raise AttributeError("%s has no property %s" % (self.__class__.__name__, property_name))

            if getattr(self, property_name) is None:
                setattr(self, property_name, other)
            else:
                raise ValueError(
                    '%s already has a %s element set.' % (self.__class__.__name__, other.__class__.__name__,))
def set_single_attribute ( self , other , trigger_klass , property_name ) : if isinstance ( other , trigger_klass ) : if not hasattr ( self , property_name ) : raise AttributeError ( "%s has no property %s" % ( self . __class__ . __name__ , property_name ) ) if getattr ( self , property_name ) is None : setattr ( self , property_name , other ) else : raise ValueError ( '%s already has a %s element set.' % ( self . __class__ . __name__ , other . __class__ . __name__ , ) )
Used to set guard the setting of an attribute which is singular and can't be set twice