Running a script from another python -


i want have ideas know how that...

i have python script parses log files, log name give argument when want run script it's that.. ( python myscript.py logname ) i'd have 2 scripts 1 contains functions , has main function don't know how able give argument when run second script.


here's second script's code:

import sys import os   path = "/myscript.py" sys.path.append(os.path.abspath(path)) import myscript   mainfunction() 

the error have is:

script, name = argv  valueerror: need more 1 value unpack 

python (just languages) share parameters across imports , includes. meaning if do:

python mysecondscript.py heeey flow down myscript.py well. so, check arguments pass.

script one

myscript = __import__('myscript') myscript.mainfunction() 

script two

import sys def mainfunction():     print sys.argv 

and do:

python script_one.py parameter

you should get:

["script_one.py", "parameter"]


Comments