Python Forum
maximum recursion depth exceeded while calling a Python object error in python3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
maximum recursion depth exceeded while calling a Python object error in python3
#5
Recursion is when a function calls itself. Your functions should not call themselves. searching should not call searching() and website should not call website(). Recursion can be used to solve lots of interesting problems, but yours is not one of them. You should use loops.

Recursion is causing your program to crash because Python puts a limit on how "deep" the recursion can go. Each recursive function call uses a bunch of memory. The memory is used to save information about what the function was doing (program counter, variable values, etc) so this can be restored when the function call returns. Left unchecked your program would use all available memory and crash, and probably cause other programs to crash. Your searching() function makes one string and then calls itself, making another string and then calling itself to make another.....

Instead of recursively calling itself your searching function should generate a string, test if that is a website, add the website if the test passes, and repeat over and over. Written this way, with a loop, it could run forever because it does not continuously consume more and more memory saving context information for yet another function call.
Reply


Messages In This Thread
RE: maximum recursion depth exceeded while calling a Python object error in python3 - by deanhystad - Aug-02-2020, 02:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python script is hanging while calling a procedure in database prasanthi417 4 504 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  Pyinstaller Maximum recursion bug scales11 8 11,031 Nov-10-2023, 10:26 PM
Last Post: SuzanneKH09
  Need help with 'str' object is not callable error. Fare 4 826 Jul-23-2023, 02:25 PM
Last Post: Fare
  pyscript index error while calling input from html form pyscript_dude 2 977 May-21-2023, 08:17 AM
Last Post: snippsat
  Understanding and debugging memory error crashes with python3.10.10 Arkaik 5 2,074 Apr-18-2023, 03:22 AM
Last Post: Larz60+
  PyRun_SimpleFile calling multiprocessing Python Class cause endless init loop Xeno 2 1,039 Sep-19-2022, 02:32 AM
Last Post: Xeno
  Error in Int object is not subscript-able. kakut 2 1,177 Jul-06-2022, 08:31 AM
Last Post: ibreeden
  python update binary object (override delivered Object properties) pierre38 4 1,762 May-19-2022, 07:52 AM
Last Post: pierre38
  Max recursion depth.... Error MeloB 2 1,886 Feb-16-2022, 05:21 PM
Last Post: MeloB
  Calling python from c++ in visual studio pdk5 0 2,157 May-24-2021, 10:18 AM
Last Post: pdk5

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020