def set_mode(self, mode_name):
        """Assign behaviours according to given mode.

        Parameters
        ==========
        mode_name (string)
            name of mode whose behaviours must be set.
        """
        ### execute the callable sitting in the 'exit_mode'
        ### attribute, so that any setups needed to exit
        ### the current mode are performed, if they exist
        self.exit_mode()

        ### get behaviour map for given mode
        behaviour_map = self.mode_behaviour_map[mode_name]

        ### assign behaviours from the map to their
        ### corresponding attributes

        for behaviour_name, behaviour in behaviour_map.items():
            setattr(self, behaviour_name, behaviour)

        ### gather the "input getting" attributes in a
        ### special container which calls all callables
        ### contained in it when executed and store it
        ### in the 'handle_input' attribute

        self.handle_input = CallList(
            (self.event_handling, self.keyboard_input_handling)
        )

        ### finally, execute the callable sitting in the
        ### 'prepare_mode' attribute so extra setups
        ### are executed for the mode, if they exist
        self.prepare_mode()
Assign behaviours according to given mode.

        Parameters
        ==========
        mode_name (string)
            name of mode whose behaviours must be set.
        
nodezator/colorsman/viewer/main.py