On 2021-08-08 at 21:37:28 -0000,
Hasan Aliyev <[email protected]> wrote:
> 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"?
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/BPUCESZHW5TODUO65WPQMV7SKQIUZPJC/
Code of Conduct: http://python.org/psf/codeofconduct/