[Python-bugs-list] [ python-Bugs-819178 ] optparse "append" action should always make the empty list.

SourceForge.net noreply at sourceforge.net
Tue Oct 7 06:47:00 EDT 2003


Bugs item #819178, was opened at 2003-10-07 06:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=819178&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Nobody/Anonymous (nobody)
Summary: optparse "append" action should always make the empty list.

Initial Comment:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=819178&group_id=5470



More information about the Python-bugs-list mailing list