How To Avoid Stack Overflow In Python