>>> python test1.py / Traceback ( File "<interactive input>", line 1

L

leroybt.rm

I don't understand why this does not work:

<FILE1> test1.py

#Import Packages
import string
#
data=0
data=data+1

print data

<FILE2> test2.py

#Import Packages
import string
#
if __name__ == "__main__":
data=0
data=data+1

print data

Traceback ( File "<interactive input>", line 1
python test.py
^
SyntaxError: invalid syntaxTraceback ( File "<interactive input>", line 1
python test.py
^
SyntaxError: invalid syntax
I just don't understand why theSE line command do not work? Im new to
Pythonwin. But not new to programming (background C,C++,java,tcl,
perl,jovial,etc...)

I decided to pick up this language because I wanted a powerful script
language at hand - tcl sucks!
 
B

Ben Finney

Traceback ( File "<interactive input>", line 1
python test.py
^
SyntaxError: invalid syntax

'python' is not a python command.

When you write a file intended to run as a script, run it as a command
from your operating system's command line: 'python test1.py'. This
tells 'python' (the program, invoked as a command) to interpret the
contents of the file 'test1.py' and execute all commands within it.

The interactive prompt, provided by typing 'python' with no arguments at
your operating system command prompt or by running PythonWin or other
tools, is for interactively typing in the Python statements found
*within* Python files:
 
C

Christopher Koppler

Traceback ( File "<interactive input>", line 1
python test.py
^
SyntaxError: invalid syntax
Traceback ( File "<interactive input>", line 1
python test.py
^
SyntaxError: invalid syntax

I just don't understand why theSE line command do not work?

The commands you use should be used from an operating systems command
line (cmd.exe on Windows), not from inside the interpreter - 'python'
is not a valid python command!
If you want to run the files from inside pythonwin (never used it
myself) I assume there's a run command inside one of the menus.
If you just want to execute the commands from inside the
interpreter... well, type them in at the >>> prompt and see what
happens!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,473
Latest member
pioneertraining

Latest Threads

Top