[Python-au] Help!
Andy Todd
andy47 at halfcooked.com
Thu Nov 20 10:21:07 CET 2003
Sophie Jarlier wrote:
> Hi everybody!
>
> Could somebody tell me how to call two python scripts in another python
> script: for example I created these 2 python scripts: script1.py and
> script2.py and I tried to code another python script as follow:
>
> python.exec("C:\Temp\script1.py")
> python.exec("C:\Temp\script2.py")
>
> What is wrong here?
> Thanks in advance for your help.
>
> Sophie
>
To run one Python script from another you import it and then invoke one
of its functions (or create an object from a class defined in it, but
that's a bit complex for this example). For instance, if your files are
like;
script1.py
---
def test1(msg):
print msg
script2.py
---
import script1
script1.test1("Hello Sophie")
Then, at the command line type
C:> python script2.py
And you should see;
Hello Sophie
This sort of thing is covered quite extensively in the Python tutorial
and other learner materials. I'd encourage you to visit
http://www.python.org/topics/learn/ for a few pointers.
There is also a mailing list specifically for people learning Python,
you can find details of it here
http://mail.python.org/mailman/listinfo/tutor
Regards,
Andy
--
--------------------------------------------------------------------------------
From the desk of Andrew J Todd esq - http://www.halfcooked.com/
More information about the python-au
mailing list