On 2021-08-08 at 21:37:28 -0000,
Hasan Aliyev
For example we can have one ArgumentParser instance, for (windows, linux), (community edition, pro edition) apps. It could give ability to show and be able to run only allowed commands based on version of os, app or some other logic.
import argparse
def some_callable(): if edition() == 'pro_edition': return True return False
parser = argparse.ArgumentParser( prog="CustomProgramm", description="CustomProgramms custom description", epilog='Epilog of this', )
parser.add_argument('--full-function', target=some_callable)
This --full-function argument will be available only if some_callable function is True, otherwise it will not be shown in command line arguments.
How/why is that better than if some_callable(): parser.add_argument('--full-function') especially if there's more than option in the "pro edition"?