Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optparse "append" action should always make the em #39381

Closed
jemfinch mannequin opened this issue Oct 7, 2003 · 4 comments
Closed

optparse "append" action should always make the em #39381

jemfinch mannequin opened this issue Oct 7, 2003 · 4 comments
Labels
type-feature A feature request or enhancement

Comments

@jemfinch
Copy link
Mannequin

jemfinch mannequin commented Oct 7, 2003

BPO 819178
Nosy @freddrake

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2004-05-05.01:42:10.000>
created_at = <Date 2003-10-07.10:47:00.000>
labels = ['type-feature']
title = 'optparse "append" action should always make the em'
updated_at = <Date 2004-05-05.01:42:10.000>
user = 'https://bugs.python.org/jemfinch'

bugs.python.org fields:

activity = <Date 2004-05-05.01:42:10.000>
actor = 'gward'
assignee = 'gward'
closed = True
closed_date = None
closer = None
components = ['None']
creation = <Date 2003-10-07.10:47:00.000>
creator = 'jemfinch'
dependencies = []
files = []
hgrepos = []
issue_num = 819178
keywords = []
message_count = 4.0
messages = ['54046', '54047', '54048', '54049']
nosy_count = 3.0
nosy_names = ['fdrake', 'gward', 'jemfinch']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue819178'
versions = []

@jemfinch
Copy link
Mannequin Author

jemfinch mannequin commented Oct 7, 2003

I was torn between "Bug" and "RFE" on this one.

Anyway, with options whose action is "append",
optparse.OptionParser will set the option to None if
it's never called. Instead, I think it should set the
option to the empty list, so code can iterate over the
list regardless of whether the option was ever given.
It keeps users from having to guard their iteration
with "if options.foo:"

Such a change would be slightly backwards-incompatible;
users who use "if option.foo is None:" form instead of
just "if not options.foo:" would run into trouble, as
well as those users who used an "else" statement in
their loops. The latter seemed like a big problem,
until I realized that those users' code *already*
guards against the empty case, and thus shouldn't run
into difficulties.

@jemfinch jemfinch mannequin closed this as completed Oct 7, 2003
@jemfinch jemfinch mannequin assigned gward Oct 7, 2003
@jemfinch jemfinch mannequin added the type-feature A feature request or enhancement label Oct 7, 2003
@jemfinch jemfinch mannequin closed this as completed Oct 7, 2003
@jemfinch jemfinch mannequin assigned gward Oct 7, 2003
@jemfinch jemfinch mannequin added the type-feature A feature request or enhancement label Oct 7, 2003
@jemfinch
Copy link
Mannequin Author

jemfinch mannequin commented Oct 7, 2003

Logged In: YES
user_id=99508

So, I *thought* I could change this to an RFE after
submitting it, but apparently not.

@freddrake
Copy link
Member

Logged In: YES
user_id=3066

I'd agree that supplying [] as the default is the right
thing to do, but the compatibility issue pretty much kills
it. This should probably become a documentation issue; a
hint to use default=[] would go a long way, and works with
the existing code.

@gward
Copy link
Mannequin

gward mannequin commented May 5, 2004

Logged In: YES
user_id=14422

First of all, this should have been filed with the 'optik'
project, not Python. Oh well, no matter, because I'm going
to refuse it anyways.
Adding "default=[]" to the add_option() call is not such a
burden, and
Optik/optparse is mature enough that I don't want to break b/w
compatibility.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant