我正在考虑将argparse用作命令行设置的真实来源,并以此方式减少大量代码。 例如,目前我正在使用单独的变量来存储argparse参数,并对它们进行一些基本操作。
# Store product sets for upload, if argument is "all", take all options from available choices
args = parser.parse_args()
product_sets = args.product_sets
if "all" in product_sets:
product_sets = PRODUCT_SET_CHOICES[:-1]
是否可以直接在argparse上进行这样的逻辑运算?
在整个脚本中使用argparse而不是将所有内容都保存在单独的设置dict或变量中是否感到烦恼?