This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add a set update action to optparse
Type: enhancement Stage: resolved
Components: Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, georg.brandl, hardkrash
Priority: low Keywords: patch

Created on 2010-01-05 02:18 by hardkrash, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7636.diff brian.curtin, 2010-01-06 05:28 patch against r77313
custom_add.py brian.curtin, 2010-01-06 05:32 example
Messages (7)
msg97242 - (view) Author: steven Michalske (hardkrash) Date: 2010-01-05 02:18
As a complement to the append action, an update action would update a set with new values.


"update"
update a set with this option’s argument

justification:
adding email addresses at the command line, makes it less code to have a unique list.
msg97250 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-05 05:42
The name should probably be "add" rather than "update", sticking with the name of the action being done on the underlying set (as update takes an iterable). Agree/disagree?

I need to add tests and docs to the patch I wrote up - I'll put it up here tomorrow.
msg97255 - (view) Author: steven Michalske (hardkrash) Date: 2010-01-05 08:42
Agreed, add is the correct word,  I used update because i created a set from the list that optarg created with append.
msg97296 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-06 05:28
After looking into it, I'm thinking this may be better off as a custom option inherited from optparse.Option. I already wrote the patch since it was small and a way to poke around optparse some more, so we'll see if anyone else likes the idea.
msg97297 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-06 05:32
custom_add.py gives an example of how you could complete this on your own without a change to optparse. Running "custom_add.py -a foo -a bar -a foo" should print out "set(['foo', 'bar'])" - ultimately the same thing.
msg97357 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-01-07 15:11
I'm not sure how much value this adds, given that you can just call set() on the list resulting from "append" actions.
msg97358 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-07 15:17
I think it's overkill, especially given the easy alternatives.
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51885
2010-01-07 17:54:01r.david.murraysetstatus: open -> closed
priority: low
resolution: rejected
stage: resolved
2010-01-07 15:17:11brian.curtinsetmessages: + msg97358
2010-01-07 15:11:15georg.brandlsetnosy: + georg.brandl
messages: + msg97357
2010-01-06 05:32:17brian.curtinsetfiles: + custom_add.py

messages: + msg97297
2010-01-06 05:28:56brian.curtinsetfiles: + issue7636.diff
keywords: + patch
messages: + msg97296
2010-01-05 08:42:47hardkrashsetmessages: + msg97255
2010-01-05 05:42:12brian.curtinsetnosy: + brian.curtin
messages: + msg97250
2010-01-05 02:18:59hardkrashcreate