Running Python script from IDLE on Windows 7 64 bit

I am trying to figure out how to successfully use Python 2.7.1 on Windows 7.
So far, I have had to use the shell (IDLE) to create scripts and then run them from the command line. I feel this slows down the learning process, and I was wondering if there is a way to start it from IDLE (I cannot create a path, so whenever I try to open or import a file I get an error message) or maybe which Is there any other program / text editor?

Any help would be appreciated! I probably just have something wrong.

+4
source share
2 answers
  • Launch IDLE. You will be offered a Python Shell window and an invitation >>> .
  • Click File, New Window. You will be presented with an “Untitled” window for editing the script.
  • Type a script in the Untitled window.
  • In the "Untitled" window, select "Run", "Run the module" (or press "F5") to run the script.
  • The dialog "Source must be saved. OK to save?". appears. Click OK.
  • In the Save As dialog box:
    a. Go to the directory to save the script.
    b. Enter a file name.
    with. Click "Save."
  • The Python Shell window displays the output of your script.
  • Modify the script and press F5 to restart the script.

Edit

Usually I don’t use IDLE and don’t immediately see a way to configure the parameters for the module, so one suggestion is to switch the IDE. Since you are using Windows 7, the pywin32 extensions contain the PythonWin IDE, and the Run command has a dialog that allows you to enter command line parameters.

+18
source

I think you mean the following function:

ExecFile (...)

 execfile(filename[, globals[, locals]]) Read and execute a Python script from a file. The globals and locals are dictionaries, defaulting to the current globals and locals. If only globals is given, locals defaults to it. 

Note:

This only applies to python 2.x, python 3 does not have execfile() , but instead sees What is an alternative to execfile in Python 3?

+3
source

All Articles