How to call a script from another?
Scott David Daniels
scott.daniels at acm.org
Thu Oct 13 11:36:20 EDT 2005
Jaime Wyant wrote:
> I think this is the simplest way to do that:
>
> import sys
> sys.path.append('/path/to/directory/containing/script')
>
> import zopescript
> zopescript.main()
>
> The code above assumes:
> o that the path you use to append contains an __init__.py in it...
I don't think this is necessary. The __init__.py is necessary
if you do something like:
import sys
sys.path.append('/path/to/directory/containing')
from script import zopescript
zopescript.main()
# or import zopescript.script; script.zopescript.main()
That is, if the directory ".../containing" needs to be interpreted as
a package.
If the script you want to call is in the same directory as the script
calling it (or any directory on the path), you can simply use:
import zopescript
zopescript.main()
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list