|
From: Peng,Bo <bp...@md...> - 2016-08-26 15:08:19
|
Hi, Zhian, We are moving to github so please start a ticket at github.com/BoPeng/simuPOP/issues for new topics. Yes, simuOpt.Params() was developed before argparse was available. Although it still has some unique features (notably validation, configuration file, and GUI), it is not as powerful and robust as argparse as a general-purpose argument parser. I have switched to argparse and found it quite nice to use in general. For your question, argparse does not have built in support for configuration files. I usually use json or yaml for such features and http://codereview.stackexchange.com/questions/110108/using-argparse-with-pa rameters-defined-in-config-file provides an example. Basically, I would give default values to all command line options in argparse and an option (e.g. -c ) to read a configuration file. The values read from configuration file (e.g. cfg = yaml.safe_load(config)) would then be used to populate the arguments. Saving parameters to a configuration file is also easy (e.g. yaml.safe_dump()) if you do not have high requirement for readability of configuration file. Hope this helps, Bo On 8/19/16, 11:57 AM, "Zhian Kamvar" <ka...@sc...> wrote: >Hello, > >I was wondering if anyone has an example of using argparse instead of >simuOpt.Params() given that the latter is now deprecated [0]? I'm looking >for an example that encapsulates reading in arguments from the command >line OR a configuration file and then writing them to a configuration >file. > >I've found a blog post [1] on advanced argument parsing and will be >attempting to refactor my script. If I come up with a solution before >anyone answers, I'll answer my own question. > >Thanks, >Zhian > >[0]: >http://simupop.sourceforge.net/manual_svn/build/userGuide_ch7_sec1.html >[1]: >http://tricksntweaks.blogspot.com/2013/05/advance-argument-parsing-in-pyth >on.html >-------------------------------------------------------------------------- >---- >_______________________________________________ >simuPOP-list mailing list >sim...@li... >https://lists.sourceforge.net/lists/listinfo/simupop-list The information contained in this e-mail message may be privileged, confidential, and/or protected from disclosure. This e-mail message may contain protected health information (PHI); dissemination of PHI should comply with applicable federal and state laws. If you are not the intended recipient, or an authorized representative of the intended recipient, any further review, disclosure, use, dissemination, distribution, or copying of this message or any attachment (or the information contained therein) is strictly prohibited. If you think that you have received this e-mail message in error, please notify the sender by return e-mail and delete all references to it and its contents from your systems. |