Sébastien Boisgérault wrote:
> Any idea why the 'options' object in
> 
> # optparse stuff
> (options, args) = parser.parse_args()
> 
> is not/couldn't be a real dict ? Or why at least it
> does not support dict's usual methods ?

Well, it's not a real dict because the original API intends it to be 
used as object attributes.  However, if you need a dict, it's pretty 
simple -- use vars() or .__dict__:

py> import optparse
py> p = optparse.OptionParser()
py> p.add_option('-x')
<Option at 0x11a01e8: -x>
py> options, args = p.parse_args(['-x', '0'])
py> options.x
'0'
py> vars(options)
{'x': '0'}
py> options.__dict__
{'x': '0'}

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

Reply via email to