Hi Ben,

On 09.08.2014 14:17, Ben Finney wrote:
Have one module of your application be responsible for the configuration
of the application::

     # app/config.py

     import configparser

     parser = configparser.ConfigParser()
     parser.read("app.conf")

Thanks for the suggestion. This way to do is new to me, and I didn't come to the idea myself. It seems like a good way to do this. But how to give an argument to this config namespace? i.e I want "app.conf" to be given as argument.

Currently my program starts like this:

def main():

    # See if the user gave a configfile
    if len(sys.argv) == 2:
        # file was given as argument
        cfg = str(sys.argv[1])
    else:
        # default file taken in the resource directory
        cfg = os.path.abspath(os.path.join(os.path.dirname(__file__),
                              os.pardir,'res','default.cfg'))

    obj = superobj(cfg)
    obj.preprocess()
    obj.process()
    obj.write()
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to