On 5/28/14 2:44 AM, onlyvin...@gmail.com wrote:
On Friday, January 19, 2001 1:22:23 AM UTC+5:30, Rolander, Dan wrote:
What is the best way to run a python script from within the interpreter?
What command should I use?
try using execfile(filename)
What type of script? python? bash? tcl? other?
If you want to use python as a shell-glue you can try using system.
>>> from os import system
>>> def <function_name>([parms])
>>> .... blah blah
>>> .... rc = system("<your_script_name")
>>>
When you call function_name within the python interpreter
your_script_name will be called using system.
OTOH, if you are wanting to run a python script within the interpreter
then just import the names you want from your_script.py file and then
call the name... like main, forinstance.
>>> from my_script import main
>>> main([parms])
Within your_script.py define a main function:
def main([parms]):
blah blah
return rc
-----
OTOH, just write the script.py file (top down procedural) and then
import it:
>>> import my_script.py
marcus
--
https://mail.python.org/mailman/listinfo/python-list