Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75945
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Fabien <fabien.maussion@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: The "right" way to use config files |
| Date | Sat, 09 Aug 2014 14:33:54 +0200 |
| Organization | Aioe.org NNTP Server |
| Lines | 35 |
| Message-ID | <ls54fh$aoe$1@speranza.aioe.org> (permalink) |
| References | <ls51q0$4ea$1@speranza.aioe.org> <mailman.12792.1407586666.18130.python-list@python.org> |
| NNTP-Posting-Host | QiumuN6L65Hlgy/sg8Mang.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com comp.lang.python:75945 |
Show key headers only | View raw
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()
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
The "right" way to use config files Fabien <fabien.maussion@gmail.com> - 2014-08-09 13:48 +0200
Re: The "right" way to use config files Ben Finney <ben+python@benfinney.id.au> - 2014-08-09 22:17 +1000
Re: The "right" way to use config files Fabien <fabien.maussion@gmail.com> - 2014-08-09 14:33 +0200
Re: The "right" way to use config files Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-08-09 12:16 -0400
Re: The "right" way to use config files Fabien <fabien.maussion@gmail.com> - 2014-08-09 19:17 +0200
Re: The "right" way to use config files Tim Chase <python.list@tim.thechases.com> - 2014-08-09 12:08 -0500
Re: The "right" way to use config files Terry Reedy <tjreedy@udel.edu> - 2014-08-09 13:29 -0400
Re: The "right" way to use config files Fabien <fabien.maussion@gmail.com> - 2014-08-09 20:14 +0200
Re: The "right" way to use config files Terry Reedy <tjreedy@udel.edu> - 2014-08-09 18:30 -0400
Re: The "right" way to use config files Fabien <fabien.maussion@gmail.com> - 2014-08-10 10:33 +0200
csiph-web