sourcing a python config file?
I wrote simple python program that rips, encodes, and gets song data from the cddb. I would like to give the user the option of customizing it to there taste. So I want to make a config file that I can store in /etc/pythonriprc or in ~/.pythonriprc. for example it would look like this
config file Code:
# if you would like to specify the location of you music directory uncomment the following |
You could use something like this section of the python tutorial. (As a shortcut, look into execfile()).
|
Something like this would work:
Code:
import re Code:
# if you would like to specify the location of you music directory uncomment the following |
@Crashed_Again
that would work :-) No need to reinvent the wheel, which I do all to often. I usually spend half a day working on an algorythm, then find out later there was aready a module made for the task. |
thanks Matir for the link, it seems something as simple as
Code:
execfile('/etc/pythonrip.rc') |
No problem. You might want to check if the file exists first, just to be clean about it. :)
|
I will do something like this
Code:
import os |
Yep, that makes sense. Might want to spit an error/warning if it doesn't exist, depending on how badly you want them to have such a config file :)
|
Ideally I wnat to use Distutils to install my modules, main script and config file. I looked at the docs, it semed a little involved , but not to hard.
|
All times are GMT -5. The time now is 04:04 AM. |