I believe that what you are looking for is the import statement. If you have a Python file, say test.py, and wish to run the program in that source file while in the interpreter prompt, you can enter
and, provided that the file test.py is in the same directory that you launched the Python interpreter from, you should be able to run the program, as well as access it's variables, call it's functions, etc. once it is imported.
Mind you, this is not the usual manner in which Python programs are run. It is more typical to have the .py files associated with pythonw.exe, which allows you to run the program just by double-clicking on the file. See the link Gribouillis posted for more details.
If, rather, you are looking to edit and test the program in question, you would be better off running IDLE (and simple integrated development environment that should have come with your Python distribution), which has a window for the interpreter prompt but also allows you to open separate editing windows for working on your source files. If you launch IDLE, the go to File-> Open File... and select your test.py file, it will open a window showing the source code; you can then run the program by going to Run-> Run Module in that window. IDLE takes a bit of getting used to, so you might consider a more powerful IDE such as Dr Python (very simple to learn and use, but only supports Python 2.x, and you need to install wxWindows before running it), PyPE, or Eric (much more powerful and complete, and a bit tricky to set up as you need to install both Qt4 and PyQt4 before running the installation).
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...