Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:06:54+00:00 2026-06-13T12:06:54+00:00

this is my function Foo: def Foo(n=10): if 1<n<=10: for i in range(1, 10):

  • 0

this is my function Foo:

def Foo(n=10):
    if 1<n<=10:
        for i in range(1, 10):
            #### Do_Something
            Foo(n-1)

I get RuntimeError: maximum recursion depth exceeded, which is frustrating since I was expecting Foo’s recursion depth to be 10+, nowhere near python’s default 500 limits.
I know I’ll be getting gigantic amount of stacks with this Foo, but that is bearable. I tried increasing sys.setrecursionlimit and still getting RuntimeError. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:06:55+00:00Added an answer on June 13, 2026 at 12:06 pm

    The documentation of sys.setrecursionlimit specifies that the recursion limit is actually the depth of the python stack.

    EDIT I don’t know why you’re hitting the recursion limit, but you’re probably not hitting because of this function (I’ve modified it so that it prints the maximum times it is on the stack):

    count = 0
    maxcount = 0
    
    def Foo(n=10):
        global count
        global maxcount
        count = count + 1
    
        if(count > maxcount):
            maxcount = count
            print maxcount
    
        if 1<n<=10:
            for i in range(1, 10):
                #### Do_Something
                Foo(n-1)
        count = count - 1
    
    Foo(10)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

consider this simple function def foo(l=[]): if not l: print List is empty else
Suppose I have a function like this (I use akka 2.0.2): def foo(message: String):
I have a script which similar to this: foo.php class Foo { function Foo()
In Scala (2.7), if I have this function: def foo(args: Array[String]) = for (arg
Suppose I have this function signature: def foo(a=True, b=True, c=True, d=True, e=True): I've decided
I was writing a python function that looked something like this def foo(some_list): for
I have a function like this: def foo(bar): ... Now bar can either be
Or, in other words, how to make this work: function foo(){} //do something that
Is this even possible? function foo() { // do stuff } foo.prototype = {
If I have a function like this: function abc($a,$b,$c = 'foo',$d = 'bar') {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.