optparse

Sébastien Boisgérault Sebastien.Boisgerault at gmail.com
Wed May 11 16:33:20 EDT 2005


Steven Bethard wrote:
> 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.

Sure ;). But what are the pros of this choice ? The option __str__
mimicks the behavior of a dict. Why not a full interface support
of it ?

> However, if you need a dict, it's pretty
> simple -- use vars() or .__dict__:

Agreed. 100%.

SB




More information about the Python-list mailing list