I want to create a file called config.py
and put some settings inside a dictionary for whenever you need to invoke these parameters.
But how do I call this parameter in Python?
For example, I'm going to create the class Config
.
class Config:
@classmethod
def getConfig(self):
parameters = {
'url_m' : 'domain',
'url_ws_m' : 'domain.api',
'url_get_token' : 'domain.token',
'url_external_access' : 'external',
'name_ws_m' : 'service'
}
return parameters
In the other app I did so:
from pp.core.Config import *
.
.
.
a = Config().getConfig()['url_m']
So it worked.
But is there a more elegant method of importing the class with the method, or is this the right way to do it?