change in the each function

Issue #26 wontfix
created an issue

Hi there when i was working on a project a problem came up and i made the following changes to resolve it. Hope it is usefull. If func is not supplied by the user the function returns a list of the elements and their corresponding indexes code: {{{


def each(self, func=False): """apply func on each nodes if func is not suplied return a list of the elements and it's index """ if not func: return [(i,e) for i,e in enumerate(self)] else: try:

            for i, element in enumerate(self):
                func_globals(func)['this'] = element
                if callback(func, i, element) == False:
            f_globals = func_globals(func)
            if 'this' in f_globals:
                del f_globals['this']
        return self


Comments (2)

  1. Log in to comment