Delete argparser.py template, it's in the sublime folder.
This commit is contained in:
parent
b4e6f448a1
commit
9d8f1e9cec
1 changed files with 0 additions and 50 deletions
|
@ -1,50 +0,0 @@
|
|||
## SINGLE
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
def example_argparse(args):
|
||||
print(args)
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument('required_positional')
|
||||
parser.add_argument('optional_positional', nargs='?', default=None)
|
||||
parser.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
||||
parser.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
||||
parser.set_defaults(func=example_argparse)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
args.func(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
## MULTIPLE
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
def example_argparse(args):
|
||||
print(args)
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
p_example = subparsers.add_parser('example1')
|
||||
p_example.add_argument('required_positional')
|
||||
p_example.add_argument('optional_positional', nargs='?', default=None)
|
||||
p_example.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
||||
p_example.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
||||
p_example.set_defaults(func=example_argparse)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
args.func(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
Loading…
Reference in a new issue