Accept a range of numbers in the form of 0-5 using Python's argparse?

Viewed 6621

Using argparse, is there a way to accept a range of numbers and convert them into a list?

For example:

python example.py --range 0-5

Is there some way input a command line argument in that form and end up with:

args.range = [0,1,2,3,4,5]

And also have the possibility to input --range 2 = [2]?

2 Answers
Related