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

The Archive Base Latest Questions

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

def test(name): print name:, name func = test func(testing) # it works, as I

  • 0
def test(name):
    print "name:", name

func = test
func("testing") # it works, as I know that the function test accepts one parameter.

My question is, what if “test” has varying number of arguments depending on the scenario and how “func” knows how many number of arguments to pass and what are those arguments name.

Sorry, if I am not clear. This would give more clear picture on the scenario.

I have a function dispatcher.

testcase_obj  = testcase() # A object of a class    
if command.startswith("test1"):    
    output = exec_test1()    
elif command.startswith("do_test"):    
    output = exec_do_test(testcase_obj)

Now, I want to wrap a function whenever user sends an option while executing the script. I changed above code as:

testcase_obj  = testcase() # A object of a class    
if command.startswith("test1"):    
    func = exec_test1() # Mistake, this should be func = exec_test1
elif command.startswith("do_test"):    
    func = exec_do_test(testcase_obj) # I don't know how assign exec_do_test along
                                      # with its parameter to 'func'. I don't want to
                                      # to call exec_to_test.

if option_given:    
    func = wrapper_func(func)    
    output = func() # At this point I don't how many parameters that "func" takes.
  • 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-13T06:54:55+00:00Added an answer on June 13, 2026 at 6:54 am

    Try the inspect module

    import inspect
    inspect.getargspec(func).args
    

    will give:

    ['name']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class test: def __init__(self): test_dict = {'1': 'one', '2': 'two'} def test_function(self): print self.test_dict
The following code: class MyClass(): def test(self): self.__x = 0 def __setattr__(self, name, value):
I need some like this: module One def test; puts 'Test One'; end end
You want to write unittest -cases for a function like that: def test_me(a): for
How can it be that this test case import unittest class PropTest(unittest.TestCase): def test(self):
def test(): print 'test' def test2(): print 'test2' test = {'test':'blabla','test2':'blabla2'} for key, val
That's one.py: test = {'1': [1, 2, 3, 4, 5, 6, 7, 8, 9,
I'm trying to unit test some code that looks like this: def main(): parser
I have this test case def setUp(self): self.user = User.objects.create(username=tauri, password='gaul') def test_loginin_student_control_panel(self): c
Assume I have the following ; def test(): while 1: a = b time.sleep(60)

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.