Forums for the Business Analyst

 
  Modern Analyst Forums  Business and Sy...  General  Python function in separate file: they all require the same parameters. How to make global variable
Previous Previous
 
Next Next
New Post 9/12/2020 3:42 AM
Informative
User is offline jainsaniya
1 posts
No Ranking


Python function in separate file: they all require the same parameters. How to make global variable  
Modified By Chris Adams  on 9/13/2020 6:03:35 PM)

My question is the following:

I have a script which requires around 10 input variables to run. Those variables are required in many of the functions I use. They are defined in the main file of my script.

Currently, all the functions I need are coded in my main file. Thus, I don't need to add in those functions extra parameters corresponding to those variables (because python functions can read "global" variable from a same file). But I would like to make my program cleaner by putting those functions in separate files. The issue with that is that all the functions would require in their definition those 10 input variables as parameters, which would be a big mess in the code.

How can I code this efficiently ? Again: I have about 10 variables in my script that I might change manually for each run. If I want to have my functions in separate files I would need to add 10 parameters to each of the functions. How to avoid that and to make my code clean ? My 10 variables are main parameters of my script and I want them to be defined in my main file.

If this is not the good place on stack exchange to ask the question, please tell me on which site I should ask.

 
Previous Previous
 
Next Next
  Modern Analyst Forums  Business and Sy...  General  Python function in separate file: they all require the same parameters. How to make global variable

Community Blog - Latest Posts

m_anst
m_anst
What Does Success Look Like? I challenge Business Analysts to view requestors’ requirements as an opportunity to define success. Too often, teams fall into a trap focused on requestors’ prescriptive requirements that are meant to serve as roadmaps for developers and testers. When you limit your view of requirements to this prescripti...
0 Responses
Mariya Kotsupalova
Mariya Kotsupalova
They say the best criteria of Business Analyst’s success are a happy customer (business) and a happy engineering team. But what does it mean? How can we break down happiness and measure it? These are precisely the questions my 8 BAs team and I tried to answer this year. The result was a surprisingly efficient pair of surveys we developed and ...
0 Responses
Rajesh-N
Rajesh-N
Explore the Benefits of RPA's Adoption Across Segments In the past few years, we have seen steady growth in Robotic Process Automation (RPA). It gathered momentum in 2019 and became a hot topic in IT and business circuits in 2020. The power of process automation will be felt even more strongly, propelling its adoption as a replacement f...
0 Responses






Copyright 2006-2020 by Modern Analyst Media LLC