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.

Author uniqueg
Recipients Danh, alclarks, atfrase, bethard, brandtbucher, calestyo, paul.j3, rhettinger, shihai1991, uniqueg, wm
Date 2021-03-20.14:58:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616252338.49.0.291682566607.issue11354@roundup.psfhosted.org>
In-reply-to
Content
Given that people were asking for real-world use cases, here's one: high-throughput sequencing, e.g., in RNA-Seq (https://en.wikipedia.org/wiki/RNA-Seq), typically yields either one or two output files, depending on the type of the sequencing library. As the processing of these library types is very similar, bioinformatics tools dealing with these inputs thus typically have APIs that take exactly 1 or 2 files as inputs. As there is quite a wide range of tools for dealing with such inputs, several of which implemented in Python, I believe there is indeed an interest in this functionality. On a more conceptual note: it is also consistent with similar and often-used functionality in regexes, from which, I suppose, the '+' and '*' notation is borrowed.

Currently implementing such a tool, I ran into the argparse limitation described here: either I (a) use a positional param with nargs=1 for the first file and define an optional param for the second file (inconsistent, non-intuitive and semantically incorrect API, because if there IS a second file, it is not really optional), (b) use nargs='+', do the admittedly simple post-processing/validation and either ignore keep the auto-generated usage string(wrong/misleading), hardcode the correct usage string (maintenance burden because of several optional params) or apply this patch (or just the auto-usage generation function), which seems rather expensive, or (c) have the user pass the second file in one string, separated by a comma or similar (also not very intuitive and needs some checks to ensure that the filename/s don't actually include commas).
History
Date User Action Args
2021-03-20 14:58:58uniquegsetrecipients: + uniqueg, rhettinger, bethard, Danh, wm, paul.j3, atfrase, brandtbucher, shihai1991, alclarks, calestyo
2021-03-20 14:58:58uniquegsetmessageid: <1616252338.49.0.291682566607.issue11354@roundup.psfhosted.org>
2021-03-20 14:58:58uniqueglinkissue11354 messages
2021-03-20 14:58:58uniquegcreate