Just found out something rather cool.

A very easy way to run a Python file on Windows through the command prompt.

Just open up the command prompt, and just type the name of your file. Mine was script1.

No need to add .py. Windeos uses Registry to look for files in the CMD. And when it finds your program (Python) it knows that it's a Python program.

Pretty neat.

Sorry for not replying sooner, was busy with school.

Anyways, I found out that the only way to fix my problem was to reinstall Python to the correct Directory. From now on, any programming language I try to learn will be installed correctly haha.

I also had to do the cd C:\Python30 command on the command prompt.

[QUOTE=griswolf;1342398]Hmm. First check: Is script1.py a pure text file? If not, there's the problem.

Otherwise: Windows or unix-like system?
[]If unix-like try chanting [icode]python [I]full/path/to/script[/I][/icode] where that full path might be [icode]./script1.py[/icode]
]If Windows, try the same sort of thing with the slashes tilted the other way

If you still have trouble: Can you invoke python to create an interactive Python session with the [icode]>>> [/icode]prompt? If that works, then you may have a newline incompatibility (though it should not matter). Try looking at your text file with something like od -c (octal dump utility).

If you did not get a prompt, then expect to find that your PATH environment is set so you have something spelled 'python' on your path ahead of the real one. If in unix-like environment, chant [icode]type python[/icode] and if the result is confusing try [icode]which python[/icode] I don't know how to do that in Windows...[/QUOTE]

Since your code in the other reply didn't work, I'll reply to this post.

I used the code you gave me
[code]rm -f check.py
echo "print('that worked')" > check.py

python ./check.py[/code]

I get an invalid syntax at the check part here
[code]rm -f check.py[/code]

It returns the message "Invalid Syntax."

I'd like to ask you some question regarding your post.

I hope you don't mind the dumb questions.

My first question is, what do you mean by pure text file?

Here's some info that might also help (or I hope it does).

I'm running Python 3.0.1 on ...

[QUOTE=woooee;1342475]The directory either has to be in the PATH or you can call it in the current directory with
python ./script1.py
or just
./script1.py if on Linux and the script is executable with the bash shebang.

Still can't get it to work with python ./script1.py

I'm currently reading a huge Python book. I've just written my first Python code (from this book).

[CODE]import sys
print(2 * 100)
x = 'spam!'

It works fine and I get the results I want.

The only problem I have right now is running it off the system Shell prompt.

I'm typing
[CODE]python script1.py[/CODE]

And that doesn't work. I'm also typing
[CODE]% python script1.py[/CODE]

I'm getting this syntax error
[CODE]File "<stdin>", line 1
python script1.py

SyntaxError: invalid syntax[/CODE]

What am I doing wrong? I have tried both Python Command Line and CMD just to test anything.

Edit: It seems that I haven't to place a full directory path. Can someone help me out with this?

Would you guys recommend this to a newbie? I'm having a hard time doing the third exercise and wondering if I should give up on pyschool (Not Python in general).

[CODE]>>> python helloworld.py
SyntaxError: invalid syntax[/CODE]

Why is it that I can't run my program like this? It says that the invalid syntax is helloworld

[QUOTE=vegaseat;1328245]First of all Python 3.2 is a alpha release for testing by experts.
Use a stable production release like 3.1.2 or even better Python 2.7[/QUOTE]

Thanks for the suggestion. I'll download it right away.

[QUOTE=woooee;1327401]Another beginner tutorial that might make more sense is [URL=http://www.freenetpages.co.uk/hp/alan.gauld/tutcont.htm[/URL]Learning To Program[/URL][/QUOTE]

Had to right click on your link to get it to work.

Anyways thanks for everything. You have made my day, and possibly my life .:Grin:.

Edit: I see you fixed the link.

[QUOTE=woooee;1327379]The book teaches Python 2.x. In Python 3.x, print is a function, so the last line would be
In the future please include the actual error message, as it is almost impossible to debug when a program is larger, without knowing exactly what is wrong.[/QUOTE]

Thanks for the info. I'll get back to work now.

It was a bit confusing since I still don't know what a function is. The book takes you from the Hello World program to this.

Edit: I'm taking a guess here, but if I ever stumble upon a problem that is function related, would I need to add () to try and fix it?

I know it's one of those programming languages thought of as an easy thing to learn (or so it seems like it). My problem is not with the difficulty of learning the language, rather the outdated guides and the problems with Python 3.2.

So I looked into a book called Diving into Python. It's free and I thought I would give it a go. It directed me to a website with a download to Python 3.2. I downloaded it and now I'm regretting of trying to learn Python. I don't like to give up easily, but I think this might be the only exception. I have no coding knowledge (well I did learn a bit of C++) so I can't really mess with anything. I'm trying to write this code

[CODE]def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.

Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])

if name == "main":
myParams = {"server":"mpilgrim", \
"database":"master", \
"uid":"sa", \
"pwd":"secret" \
print buildConnectionString(myParams)[/CODE]

but I get a syntax error at [CODE]buildconnectionstring(myParams)[/CODE]

When I try to run it, it says syntax error occurs at that part.

I'm not sure (since I'm no geek when it comes to Programming), but I'm thinking that maybe because the book I'm using is old, some thing might not be compatible with Python 3.2.

I'm sorry if it seems like I'm an incompetent fool who needs someone to hold his hands, but as dumb as this may sound, programming ...