Python Forum
python manage variables across project level
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python manage variables across project level
#1
Hi Team,

how to manage variables which can be used in project level, instead of passing all variables from main def

In my project I am using total 10 modules. [no class module used]

in main function I have created all variables.
few functions are calling in same module, and passing 80% job to another module. main2 to finish.

from main_function I am passing all variables to main2 function which is in another module
and importing all functions from other module into main2 module.
and doing jobs.


import sys
import json

def main():    
    var1 =   sys.argv[1]
    var2  =   sys.argv[2]
    var3  =   sys.argv[3]
    var4  =   sys.argv[4]
    var5  =   sys.argv[5]

    with open("DBConfig.json","r") as myconfig:        
        obj = json.loads(myconfig)
        
        server = obj[1]
        database = obj[2]
        constant_path = obj[3]
        logging_path = obj[4]
        
        hd ,conn = connect_database(server,database)
        hd, conn = connect_SP(server, database,logger)
        
        #function call with
        main2(var1,var2,var3,var4,var5,var6,server,database,constant_path,conn,logging_path)
            pass
        
if "___name__ " == "__main__":
    main()
Reply


Messages In This Thread
python manage variables across project level - by mg24 - Nov-11-2022, 09:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do you manage script? kucingkembar 14 2,975 Oct-15-2022, 06:32 PM
Last Post: Gribouillis
  Python, how to manage multiple data in list or dictionary with calculations and FIFO Mikeardy 8 2,784 Dec-31-2021, 07:47 AM
Last Post: Mikeardy
  how to manage crypto trading flooding data from exchange servers Mikeardy 0 1,293 Dec-26-2021, 08:31 PM
Last Post: Mikeardy
  API Gateway to manage multiple API's get put data robsuttonjr 2 2,613 Mar-09-2021, 04:09 PM
Last Post: robsuttonjr
Photo Locate Noise floor level for a spectral data in Python Ranjan_Pal 1 3,141 Dec-19-2020, 10:04 AM
Last Post: Larz60+
  Manage user names in TRAC susja 3 6,527 Dec-06-2020, 09:34 PM
Last Post: susja
  How to manage multiple datasets in Python ThePhantom 2 1,987 May-06-2020, 12:17 AM
Last Post: ThePhantom
  how to manage an input() rodrigoH 1 1,701 Mar-16-2020, 12:24 AM
Last Post: jefsummers
  Questions re: my first python app (GUI, cross-platform, admin/root-level commands)? DonnyBahama 0 1,788 Feb-27-2020, 08:14 PM
Last Post: DonnyBahama
  Easier way to manage dependencies? Tylersuard 2 2,419 Jan-01-2020, 09:19 PM
Last Post: Tylersuard

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020