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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file argparse-oappend-0.0.1.tar.gz.
File metadata
- Download URL: argparse-oappend-0.0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f64234d0a06b01734dba63b67467796f3e71c93bee672c8318b7655ddf4291b8
|
|
| MD5 |
3a1af35f22aeb407f7403d49234670d9
|
|
| BLAKE2b-256 |
f5b1df42691bd68579c50f64fbbfc9c3cb529abe0bae84e25524ef227f40fb04
|