I want to know how to execute a python script using the command line. This is my code in Arithmetic.py:
def main():
print 'spam'
if __name__ == '__main__':
main()
When I type
python Arithmetic.py
I get an Syntax Error on the "c"
File "ipython-input-11-0770a0dfdadd", line 1
python Arithmetic.py
Any ideas? Thanks!
It looks like you're trying to type the python Arithmetic.py
command into an IPython shell. Instead, make sure you're using your operating system's command prompt. (You can get out of a Python or IPython shell by typing exit()
.)
On Windows, the command prompt looks like this:
C:\Users\Carter>
On Linux, the command prompt looks like this:
carter@carters-computer:~$
In Mac OS X, it looks like this:
Carters-Macbook:~ csande$