[Numpy-discussion] Reading automatically all the parameters from a file
Tony Yu
tsyu80@gmail....
Wed Nov 30 13:14:39 CST 2011
On Wed, Nov 30, 2011 at 1:49 PM, Neal Becker <ndbecker2@gmail.com> wrote:
> My suggestion is: don't.
>
> It's easier to script runs if you read parameters from the command line.
> I recommend argparse.
>
>
I think setting parameters in a config file and setting them on the
command line both have their merits. I like to combine ConfigObj with
argparse; something like:
#~~~
parser = argparse.ArgumentParser()
<add arguments to parser here>
cfg = configobj.ConfigObj("params_file.cfg")
parser.set_defaults(**cfg.config)
#~~~
Then call parser.parse_args, which will override parameters in the config
file by specifying values on the command line.
Cheers,
-Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20111130/cd016377/attachment.html
More information about the NumPy-Discussion
mailing list