Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

Is there a way to organize configuration file with structured python application without framework

$
0
0

I'd like to use configuration globally so that many python function can use without read a file every time when it needs

So I have a file app.py

from views.run import runif __name__ == '__main__':    run()

config.py

config['db_host'] = 'localhost'config['port'] = '3306'config['user'] = 'root'config['pw'] = 'password'

and views/run.py

def run():    host = config['db_host']    port = config['port']    user = config['user']    pw = config['pw']

views/run1.py

def run1():    host = config['db_host']    port = config['port']    user = config['user']    pw = config['pw']

is there a way to setup the config globally in pythonic way?


Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>