[issue2444] Adding __iter__ to class Values of module optparse

Shawn Morel report at bugs.python.org
Wed Apr 2 15:08:47 CEST 2008


Shawn Morel <shawn at technosmores.com> added the comment:

gpolo: The argument still doesn't hold. As you point out, it's the 
Values class output from __str__ and other behaviour that is being un-
pythonic and leading you to believe it's a dictionary. Adding the 
__itter__ method would only make this worse. Then someone else would 
surely ask to have another __*__ method added since dictionaries support 
it but values don't.

The question then is one for optik. Why doesn't values simply inherit 
from dict and why does it insist on using __setattr__ rather than 
actually behaving completely like a dictionary. I know I was completely surprised by the following:

>>> (opts, args) = parser.parse_args(values={})
>>> print opts
{}
>>>

----------
nosy: +shawnmorel

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2444>
__________________________________


More information about the Python-bugs-list mailing list