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

Angular is a powerful open-source web application framework developed and maintained by Google. It is designed to simplify and streamline the process of building dynamic and interactive web applications.  Angular was first introduced in 2010 as "AngularJS" by Misko Hevery and Adam Abrons during their work on a project called "...
Introduction In today's data-driven world, businesses are constantly looking for ways to gain valuable insights and make informed decisions. Power BI, a powerful business intelligence and data visualization tool developed by Microsoft, has emerged as a game-changer for organizations across various industries. In this article, we will explore...
As a business analyst, your resume is a crucial marketing tool for showcasing your skills, experience, and accomplishments to potential employers. You have the opportunity to make the best impact and secure an interview when you compose your resume. Yet, competition for jobs is fierce, so it is vital to be aware that your resume stands out from the...

 






 

Copyright 2006-2023 by Modern Analyst Media LLC