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 8992913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:04:12+00:00 2026-06-15T23:04:12+00:00

This kind of a broad question. As I find myself having to write longer

  • 0

This kind of a broad question.

As I find myself having to write longer and longer scripts, I find that my instinct is to break everything up into bite-sized functions; however, this ultimately results in functions calling functions calling functions calling functions…. and I’m wondering if I’m completely thinking about this the wrong way.

Here’s what an abridged script might look like. Sorry it’s kind of contrived.

def simple_task_1():
    return

def simple_task_2():
    return

def simple_task_3():
    return

def simple_task_4():
    return

def complex_task_1():
    simple_task_2()
    simple_task_3()
    simple_task_4()
    return

def startup():
    simple_task_1()
    complex_task_1()
    simple_task_4()

def finish():
    # other function calls
    return

def main():
    startup()
    finish()

So, is this the correct way to be using functions? Is there an objective point where you can say you’ve made too many function calls inside each other? Should I even be making functions for tasks that only end up being done once?

  • 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-15T23:04:14+00:00Added an answer on June 15, 2026 at 11:04 pm

    Python has a “recursion” limit. If you hit that, then you’re probably using too many functions, otherwise it’s probably not a big deal — Usually you can only hit the recursion limit if you’re calling a function recursively (and then usually because you did something wrong and didn’t break when you should have).

    The point of functions is to make your life easier. If you find that you have too many functions and you’re not actually making your life easier, then it’s probably a problem. For example:

    def add(x,y):
        return x+y
    

    Is a pretty pointless function and it’s probably best avoided, however, if you want sinc:

    def sinc(x):
        return math.sin(x)/x
    

    That might actually be useful since the new function name is more descriptive than the code which is executed within. Also, later if you find that you need to remove the singularity at x=0, you can add that into sinc easily.

    Ultimately, readability is what counts. If using a function makes your code easier to read, then it’s probably worthwhile (even if you’ll only call it from one place and could inline it easily). There are some grey areas if you’re really concerned about performance (functions do take a little longer to execute than inline code), but you shouldn’t use that as an excuse to inline something that is hard to read unless you can reliably demonstrate that it is a performance bottleneck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(This question may seem easy or kind of noobish, by that I pardon my
I understand that this is a very broad question, but I was very curious
This is kind of a broad question but I wanted to ask anyways. Hopefully
This kind of seems like a noob question, but I could not find an
I know this is kind of a broad question, but I'm new to servers.
this is just kind of a broad question to get some starting points. I
I understand that this is a very broad question, but a short it depends
I have this kind of question. In my form, i got this as a
I am sure that this kind of questions must have been asked before, but
This kind of builds up on Already asked question ... However here, say, I'm

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.