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

  • Home
  • SEARCH
  • 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 9132843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:22:59+00:00 2026-06-17T08:22:59+00:00

I need to create a function which can: Inspect input arguments and get the

  • 0

I need to create a function which can:

  1. Inspect input arguments and get the number of inputs and their values
  2. Create a loop, and add string ‘_in’ after each input name
  3. Make the new inputs global
  4. Assign new inputs with old values

I tried to use inspect.getargspec() but it seems like this should be called outside the function. So any suggestions?

Here is the pseudo code:
Define this function:

def set_global(a1, a2, a3, .... an):
    #the number of arguments is not fixed and we need to detect that
    for old_input in total input:
         new_input_name=str(old_input.name)+'_in'
         global new_input_name 
         new_input_name = old_input.value
  • 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-17T08:23:00+00:00Added an answer on June 17, 2026 at 8:23 am

    I really think you’re looking for the globals function.

    a = 1
    globals()['a'] = 2
    print a  #2
    globals()['a_in'] = 2
    print a_in  #2
    

    You could put this in a function:

    def do_something_with_globals(**kwargs):
        for k,v in kwargs.items():
            globals()[k+'_in'] = v
    

    Which could be called like this:

    a = 1
    b = 2
    do_something_with_globals(a=a,b=b)
    print a_in
    print b_in
    

    But, honestly, I really don’t think this is a good idea…

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

Sidebar

Related Questions

Need some help in creating function which can create folders recursively with giving path:
I need to create a function which will have large amount of parameters can
I need to create a function which can be executed only once, in each
I need to create a function which rounds decimal numbers like this: Round($32.95, 0)
I need to be able to create a seperate function which creates a total
I need to create a function that uses a loop. This function will open
I need to create a function which appends a value to a vector and
Hoping someone can help me. I'm trying to create a function which adds a
I need to create a function (in R) which: - given N possible variables
I need to create an obscuring function which replaces a clear-text password in line,

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.