RecursionError: maximum recursion depth exceeded while calling a Python object


#1

Hi,
So I am kind of new to python and I am receiving this error and have no clue what it means.
I am trying to run random.radiant through a range of numbers.
The complexity is that I am doing this with 3 different ranges while all 3 random results need to conclude to a certain result which would return True. If they dont, it runs all 3 random ranges again until it receives a True from the loop.
def random():
x = random.randint (0,n+1) ### n represents a changing variable
y = random.randint (0,z+1) ### z represents a changing variable
q = random.randint (0,t+1) ### t represents a changing variable
outer_function(x,y,q)
if outer_function(x,y,q) is True:
Break
if outer_function(x,y,q) is False:
random()

like I mentioned above, I then use a while loop to plug in x,y and q in to an outer function, if that outer function returns a False then the above tries once more the random until it outputs a True from the outer function.
Thanks for the help


#2

Check that your function isn’t invoking itself. That would be the cause.

Is it possible to overwrite a module? If so,

would be doing just that.

Best advice, don’t use reserved words or module names to name your functions.

import random

or

from random import randint

Give the function a name that has no conflicts, save, and refresh before running.

One concern, break does not interrupt recursion. It needs a for or while loop. We need a base case to give the final return. It’s that return that starts the pop returns off the call stack process.