def add_post_step_callback(self, callback_function, obj, *args, **kwargs):
        """Add a function to be called last in the next simulation step.
                
        Post step callbacks are registered as a function and an object used as 
        a key. You can only register one post step callback per object. 
        
        This function was more useful with earlier versions of pymunk where 
        you weren't allowed to use the add and remove methods on the space 
        during a simulation step. But this function is still available for 
        other uses and to keep backwards compatibility. 
        
        .. Note::
            If you remove a shape from the callback it will trigger the
            collision handler for the 'separate' event if it the shape was 
            touching when removed.
        
        :Parameters:
            callback_function : ``func(obj, *args, **kwargs)``
                The callback function.
            obj : Any object
                This object is used as a key, you can only have one callback 
                for a single object. It is passed on to the callback function.
            args
                Optional parameters passed to the callback function.
            kwargs
                Optional keyword parameters passed on to the callback function.
                
        :Return: 
            True if key was not previously added, False otherwise
        """
        
        if obj in self._post_callback_keys:
            return False
            
        def cf(_space, key, data):
            callback_function(obj, *args, **kwargs)
            
        f = cp.cpPostStepFunc(cf)
                
        self._post_last_callback_key += 1
        self._post_callback_keys[obj] = self._post_last_callback_key    
        self._post_step_callbacks[obj] = f
        
        key = self._post_callback_keys[obj]
        return bool(cp.cpSpaceAddPostStepCallback(self._space, f, key, None))
dataset/ETHPy150Open estevaofon/angry-birds-python/pymunk-4.0.0/pymunk/__init__.py/Space.add_post_step_callback/original