Re: which configparse?

2007-12-07 Thread Sion Arrowsmith
Neal Becker  [EMAIL PROTECTED] wrote:
I've looked at configparse, cfgparse, iniparse.

configparse looks like what I want, but it seems last commit was 2years
ago.

What is the best choice?

ConfigParser is the battery included in the standard library. If
you're planning on distributing your script, consider the value
of this.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   Frankly I have no feelings towards penguins one way or the other
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

which configparse?

2007-12-06 Thread Neal Becker
I have all my options setup with optparse.  Now, I'd like to be able to
parse an ini file to set defaults (that could be overridden by command line
switches).

I'd like to make minimal change to my working optparse setup (there are lots
of options - I don't want to duplicate all the cmdline parsing with ini
file parsing code)

I've looked at configparse, cfgparse, iniparse.

configparse looks like what I want, but it seems last commit was 2years
ago.

What is the best choice?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which configparse?

2007-12-06 Thread Shane Geiger
Best, is naturally, a somewhat subjective evaluation.  That being said,
configparser is well regarded.  I have also seen these two options that
you might want to check out:

http://wiki.woodpecker.org.cn/moin/Dict4Ini
http://www.voidspace.org.uk/python/configobj.html


 I have all my options setup with optparse.  Now, I'd like to be able to
 parse an ini file to set defaults (that could be overridden by command line
 switches).

 I'd like to make minimal change to my working optparse setup (there are lots
 of options - I don't want to duplicate all the cmdline parsing with ini
 file parsing code)

 I've looked at configparse, cfgparse, iniparse.

 configparse looks like what I want, but it seems last commit was 2years
 ago.

 What is the best choice?

   


-- 
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy




signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: which configparse?

2007-12-06 Thread Joshua Kugler
Shane Geiger wrote:

 Best, is naturally, a somewhat subjective evaluation.  That being said,
 configparser is well regarded.  I have also seen these two options that
 you might want to check out:
 
 http://wiki.woodpecker.org.cn/moin/Dict4Ini
 http://www.voidspace.org.uk/python/configobj.html

+1 on configobj.  The ability to have mutli-level config files is wonderful,
and it's all dict and/or array access methods.  Wonderful.

 I'd like to make minimal change to my working optparse setup (there are
 lots of options - I don't want to duplicate all the cmdline parsing with
 ini file parsing code)

I found (at least) two areas where lots of code is unavoidable:
configuration handling and error handling.  That said, you could use
configparse (or configobj) to set the defaults of all your command line
options, like so:

cfg = configobj.ConfigObj('file.ini', file_error=True)
parser.add_option('--opt', dest='opt',  default=cfg.get('opt', None)

Hmm...now why didn't I do that in my code?  Thanks for the idea! :)

j


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which configparse?

2007-12-06 Thread Neal Becker
Martin Marcher wrote:

 Hi,
 
 On 12/6/07, Neal Becker [EMAIL PROTECTED] wrote:
 configparse looks like what I want, but it seems last commit was 2years
 ago.

 What is the best choice?
 
 that seems like configparse is the best choice. 

Thanks.  I see something right off that should be improved in configparse.

In OptionParser.__init__, a hard-coded list of arguments is passed to the
base _OptionParser.  This (predictably) is no longer current - OptionParser
now has one more optional argument.

I suspect the correct thing to do here is to allow configparse.OptionParser
to accept error_handler only as a keyword arg, and then strip it out,
passing all other args to _OptionParser.__init__.

   

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which configparse?

2007-12-06 Thread Martin Marcher
Hi,

On 12/6/07, Neal Becker [EMAIL PROTECTED] wrote:
 configparse looks like what I want, but it seems last commit was 2years
 ago.

 What is the best choice?

that seems like configparse is the best choice. I use it quite often
and no commit in 2years to me means Boy that's stable software. A
search on bugs.python.org mentions 1 enhancement to use for line in
f: instead of while 1:

Why do we always need a ton of commits? For me that means that
developement is still in progress and changes have to be expected
because it's not yet stable.

(Actually not that hard rules, but I hope you get what I meant)

martin

-- 
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which configparse?

2007-12-06 Thread limodou
On Dec 6, 2007 11:49 PM, Shane Geiger [EMAIL PROTECTED] wrote:
 Best, is naturally, a somewhat subjective evaluation.  That being said,
 configparser is well regarded.  I have also seen these two options that
 you might want to check out:

 http://wiki.woodpecker.org.cn/moin/Dict4Ini
 http://www.voidspace.org.uk/python/configobj.html

Thanks for you mentioned Dict4ini, but the new project site is in
http://code.google.com/p/dict4ini

-- 
I like python!
UliPad The Python Editor: http://code.google.com/p/ulipad/
meide wxPython UI module: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou
-- 
http://mail.python.org/mailman/listinfo/python-list