python - output of one file input to next -
how output of 1 script passed input another? example if a.py outputs format.xml how a.py call b.py , pass argument format.xml? think it's supposed work piping done on command line.
i've been hired bunch of scientists domain specific knowledge there computer programming requirements don't make sense. there's long chain of "modules" , boss adamant 1 module being 1 python script, , output of 1 module input of next. i'm new python, if design pattern rings bell let me know.
worse yet project converted executable format (using py2exe) , there still has same number of executable files .py files.
the pattern makes sense in cases, me it's when want able run each module self sustained executeable.
i.e. should want use script within fortran or similar language, easiest way, build python module executeable, , call fortran.
that not mean 1 module pr definition 1 python file, has 1 entry point, , in fact executeable.
the 1 module pr script, make easier locate code. or mail code inspection or peer review (done in scientific communities)
so requirements may mix of technical , social requirements.
anyway problem.
i use subprocess module call next module. (with close_fds set true)
if close_fds true, file descriptors except 0, 1 , 2 closed before child process executed. (unix only). or, on windows, if close_fds true no handles inherited child process. note on windows, cannot set close_fds true , redirect standard handles setting stdin, stdout or stderr.
Comments
Post a Comment