enveloop

Various utility for handling loops, recursions, etc.


Keywords
loop, recursion, infinite-loop
License
MIT
Install
pip install enveloop==0.1.0

Documentation

enveloop

PyPI version Build Status GitHub GitHub last commit

Various utilities for handling loops, recursions, etc.

Limit number of recursions

Let's say you wrote a recursive function and you want to limit number of recursions, just to be infinite loop free, or for any other reason.

from enveloop import limit_recursion_to


# let's limit the number of recursion to 100

@limit_recursion_to(100)
def my_func(arg):
    ...
    my_func(arg)
    ...


# let's limit the number of recursion and after 
# the 10th recursion run a callback function.
# callback function takes exactly the same arguments
# as the recursion function.

@limit_recursion_to(10, lambda arg: ...)
def my_func(arg):
    ...
    my_func(arg)
    ...

Changelog

0.1.0

Added:

  • limit_recursion_to()