F
Famille Delorme
Sorry if this discussion are already submited, but I don't find anything
really interresting for me.
And sorry for my bad english, it is not my native language.
I wrote a program in Python for a school project and I am in trouble.
I have make a Python script called conf.py. This file contains dictionnarys
for configuration like this:
config_sql = {
"DATABASE" : "nanana",
"USERDB" : "bob",
"PASSWORD" : "********"
}
config_script = {
"TIMETOSLEEP" : 100
"PATH" : "/home/script"
}
The config_section variable is included in each modules (script python) used
in my program
(with from config.py import config_section)
And the use is like this
from conf.py import config_sql
print config["DATABASE"]
But my master say it's better to do a class like this
class config :
def __init__(self, part=="") :
if (part=="SQL") :
self.database="nanana"
self.userdb="bob"
self.password="*******"
elif (part=="SCRIPT") :
self.timetosleep=10
self.path="/home/script"
....
and the use like this
from conf.py import config
cfg=config("SQL")
print cfg.database
We have do only a file for configuration because the administrator is no
searching for configuration.
I want know :
- what is more faster, dictionnary method or class method?
- what use more ram memory ?
- if you are administrator, what method you like for configure program ?
Note:
* the class will not have methods, it is not necessary.
* the program is composed of several modules which import
config_section.
Thank you for futures answers,
3Zen
really interresting for me.
And sorry for my bad english, it is not my native language.
I wrote a program in Python for a school project and I am in trouble.
I have make a Python script called conf.py. This file contains dictionnarys
for configuration like this:
config_sql = {
"DATABASE" : "nanana",
"USERDB" : "bob",
"PASSWORD" : "********"
}
config_script = {
"TIMETOSLEEP" : 100
"PATH" : "/home/script"
}
The config_section variable is included in each modules (script python) used
in my program
(with from config.py import config_section)
And the use is like this
from conf.py import config_sql
print config["DATABASE"]
But my master say it's better to do a class like this
class config :
def __init__(self, part=="") :
if (part=="SQL") :
self.database="nanana"
self.userdb="bob"
self.password="*******"
elif (part=="SCRIPT") :
self.timetosleep=10
self.path="/home/script"
....
and the use like this
from conf.py import config
cfg=config("SQL")
print cfg.database
We have do only a file for configuration because the administrator is no
searching for configuration.
I want know :
- what is more faster, dictionnary method or class method?
- what use more ram memory ?
- if you are administrator, what method you like for configure program ?
Note:
* the class will not have methods, it is not necessary.
* the program is composed of several modules which import
config_section.
Thank you for futures answers,
3Zen