[issue2444] Adding __iter__ to class Values of module optparse

2008-04-02 Thread Shawn Morel
Shawn Morel [EMAIL PROTECTED] 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

[issue2444] Adding __iter__ to class Values of module optparse

2008-04-02 Thread Guilherme Polo
Guilherme Polo [EMAIL PROTECTED] added the comment: I have asked that myself, shawnmore. Why not let Value subclass dict ? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444 __

[issue2444] Adding __iter__ to class Values of module optparse

2008-04-02 Thread Steven Bethard
Steven Bethard [EMAIL PROTECTED] added the comment: Subclassing dict seems like a bad idea. The options value returned by .parse_args() is not supposed to be dict-like, it's supposed to be object-like. That is, the natural way of accessing values from it is through dotted attribute access, not

[issue2444] Adding __iter__ to class Values of module optparse

2008-04-02 Thread Guilherme Polo
Guilherme Polo [EMAIL PROTECTED] added the comment: Given the disagreement found here, I suggest closing this rfe and moving further discussions to c.l.p. Thanks djc and rhettinger for your support, and, bethard and shawnmorel for your different p.o.v. __ Tracker

[issue2444] Adding __iter__ to class Values of module optparse

2008-04-02 Thread Benjamin Peterson
Benjamin Peterson [EMAIL PROTECTED] added the comment: Closing on OP's request. -- nosy: +benjamin.peterson resolution: - rejected status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444 __

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread djc
djc [EMAIL PROTECTED] added the comment: I'd like this. I had one instance where a number of options where dynamically added to the OptionParser based on loadable modules, so that I wanted to dynamically iterate over the Values returned as well. -- nosy: +djc

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: This seems to be a reasonable request. -- assignee: - gward nosy: +gward, rhettinger __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444 __

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Raymond Hettinger
Changes by Raymond Hettinger [EMAIL PROTECTED]: -- type: - feature request __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444 __ ___ Python-bugs-list mailing list

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Steven Bethard
Steven Bethard [EMAIL PROTECTED] added the comment: Why can't you just iterate over ``vars(opts)``? -- nosy: +bethard __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444 __

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Guilherme Polo
Guilherme Polo [EMAIL PROTECTED] added the comment: I consider iterating over opts to be nicer and more pythonic than using vars(opts), since the latter is just a mask over the ugly opts.__dict__ __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Steven Bethard
Steven Bethard [EMAIL PROTECTED] added the comment: But ``vars()`` is the standard Python mechanism for doing this sort of thing (that is, treating an object like a dictionary). So, while I understand that you find iterating over opts to be nicer, calling it more Pythonic is probably a misuse of

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Guilherme Polo
Guilherme Polo [EMAIL PROTECTED] added the comment: There is another reason for considering __iter__ as a more pythonic solution here. If you print opts, it may lead you to believe that it is just a regular dict, while it is not. If you were just able to iterate over it, I think it would be more

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-23 Thread Steven Bethard
Steven Bethard [EMAIL PROTECTED] added the comment: My experience in the past has been that the optik/optparse maintainer doesn't often respond to tickets in this tracker, though perhaps that has changed recently. __ Tracker [EMAIL PROTECTED]

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-21 Thread Guilherme Polo
New submission from Guilherme Polo [EMAIL PROTECTED]: Hi, Doing (opts, args) = parser.parse_args(), supposing parser is an OptionParser instance, gets you an instance of class Values into opts. This patch adds the __iter__ method to the class Values so it is possible to iterate over the

[issue2444] Adding __iter__ to class Values of module optparse

2008-03-21 Thread Guilherme Polo
Changes by Guilherme Polo [EMAIL PROTECTED]: Added file: http://bugs.python.org/file9802/optparse_py3k__iter__.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2444 __ ___