[Tutor] Running two different python applications from one module
Alan Gauld
alan.gauld at btinternet.com
Sat Jun 2 14:10:59 CEST 2007
"Norman Khine" <norman at khine.net> wrote
> I would like to write a script using python 2.5 to interact with a
> Zope
> application that is running on python 2.4.3
>
> Can I call the python 2.4.3 module from within the python 2.5, if so
> how?
You can generally import modules from older versions into
newer versions if the module is implemented in pure Python.
Where it gets messier is if the module is built in C. There
you generally need a library compiled for your version.
> For example, my script is in /home/me/python2.4/create.py
> and within my /home/me/python2.5/servers.py
>
> When running server.py I would like to run the create.py and then
> continue with my application in the python2.5
Your use of the term 'run' is confusing. What exactly do you mean?
You could:
1) use os.system to execute it as a separate process in a separate
shell
2) use execfile to run it as a separate process (in the same shell?)
3) use import to load it into your program and execute its functuions
within your process. In this case you need your sys.path to
include the python 2.4 folder
And other options on top of that. What do you actually want to do?
> Can someone show me an example from the interpreter or as a module
> that
> does this.
You can see examples of running subproceses in the OS topic of my
tutorial.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list