472,356 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,356 software developers and data experts.

Very simple question: how to run .py file using a Python editor in Windows


I am new to Python. Just started learning it. I am just trying to follow the book and run the example given in the book. I created a module by saving 2 python statements in notepad and saved the file in .py format just like the book said. the two statements are:
print 2**8
print 'test'

I saved the file as test.py. The book's example given is using shell. I am using the Python installed for Windows. I also checked the tutorials for Windows. I tried the following and none of them worked:
>>>python test.py
>>>C:\Python25>python test.py

the error message for both:
SyntaxError: Invalid syntax

For python test.py the word is high lighted in red with the error message. and for the C:\ the : is high lighted in red with the error message.

I also tried setting the path in dos using set path=%path%;c:\python25

My question is, how do I run the script using the Python editor in Windows?

Sep 25 '08 #1
4 14945
849 Expert 512MB
Um...It looks like you've fired up the Python interactive shell. Load up a command prompt (cmd.exe, aka a DOS prompt) instead and then chdir to the folder and type "python test.py" without the quotes. That ought to work, possible pythonpath issues aside.
Sep 25 '08 #2
you can run python program in editor by pressing 'F5' key
Sep 26 '08 #3
Make sure you haven't downloaded python 3.0 beta as it has turned the "print" statement into a function rather than an embedded engine call... As other people have states as well, it seems you have run python interactive shell... This is just a shell which directly executes python commands without the need of saving them... e.g.

Expand|Select|Wrap|Line Numbers
  1. >>> print 2**8
  2. 256
  3. >>> print "test"
  4. test
As you see it does the code directly. No need for saving files and loading them via command prompt. IDLE is BRILLIANT for testing code that you're unsure about. It is one of the best testing environment I've ever seen for any programming language.

Sep 26 '08 #4
this is a nice solution
Apr 13 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Lee David | last post by:
I went to the sun site and downloaded what I hope is the development part of java. I downloaded JDK5 with Netbeans. I installed it and now have a folder in my program group "Netbeans". Is that...
by: diffuser78 | last post by:
I have just started to learn python. Some said that its slow. Can somebody pin point the issue. Thans
by: ago | last post by:
I have just discovered Python Scripter by Kiriakos Vlahos and it was a pleasant surprise. I thought that it deserved to be signalled. It is slim and fairly fast, with embedded graphical debugger,...
by: true911m | last post by:
This is a simple walkthrough to get PyInstaller up and running. I decided to give PI a try, because it claims to be more selective about what it bundles into its executable files by default, and...
by: true911m | last post by:
Here's a little walkthrough to get py2exe up and running. I'm not an expert, so I can't help much with any problems you might have. This is what worked for me. The result here will be to convert...
by: Paulo da Silva | last post by:
Hi! I was told in this NG that string is obsolet. I should use str methods. So, how do I join a list of strings delimited by a given char, let's say ','? Old way:
by: maria | last post by:
I only use C++ with Visual Studio 6.0 for string manipulations in thousands of HTML pages on my website. Many times, the output files of many of my C++ programs contain a spanish question mark ()...
by: corvettecraz92 | last post by:
I want to create a program where a user can type what ever they want to, have it saved to a file, and the be able to re-open it and read it. How would I do this? Thanks!
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.