Skip to content

wrwrwr/argparse-oappend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

argparse-oappend

Provides oappend action for argparse that works almost like append, but skips the default list if the user gives any value for the option.

See issue 16399 for a discussion.

Example

You may import OverrideAppendAction and register it with a parser or use the provided parser:

from oappend import OverrideAppendArgumentParser

parser = OverrideAppendArgumentParser()
parser.add_argument('-n', action='oappend', type=int, default=[1, 2])
args = parser.parse_args(['-n3', '-n4'])  # Namespace(n=[3, 4])

With the standard append action the option would be set to [1, 2, 3, 4], combining your default with user choices.

Installation

pip3 install argparse-oappend

About

An append action for argparse that overrides the default.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages