Computational Physics

Dr. Ayars

#!/usr/bin/env python

# How to get things directly into a program from the command line:
import sys

# sys.argv is a list of whatever the command was. 
# For example:

print sys.argv

# Here's something you could do with this, as a simple example:

sum = 0

for number in sys.argv[1:]: # loop over all things after sys.argv[0].
    sum += int(number)      # This is the same as sum = sum + int(number).

print sum