2

I want to run Parser for command-line options, taken from official Python 2.7 documentation https://docs.python.org/2/library/argparse.html#module-argparse using MS Visual Studion 2015 (Python Tools). I created script named prog.py.

#file_name='prog.py'
import argparse

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
                    help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
                    const=sum, default=max,
                    help='sum the integers (default: find the max)')

args = parser.parse_args()
print args.accumulate(args.integers)

I usually run my scripts selecting several lines of code and pressing Ctrl+E,E. But this time I need to run the whole script with additional command line arguments. In this particular case I want execute commands:

python prog.py -h

to see help from my script. And:

python prog.py 1 2 3 4
python prog.py 1 2 3 4 --sum

to see how it worked. The result must be visible in Python 2.7 Interactive window in Visual Studio Environment. How do they do this in MS Visual Studio 2015?

1 Answer 1

2

You can right-click on the VS Project containing your script and goto Properties. Then under the Debug tab you can add "Script Arguments" that get passed in when you hit Start (F5).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.