简体   繁体   中英

Is this a wrapper script? What is the correct name for it? (Python)

execfile("es.py")
execfile("ew.py")
execfile("ef.py")
execfile("gw.py")
execfile("sh.py")

print "--Complete--"

It is a kind of wrapper script, i guess, but there is no "correct name" for that as it is not very pythonic to write something like that.

One would probably write something like

import es
import ew
### ...

es.run() # assuming es code is in a run function
ew.run()
# ...

To expand on that, in python, a file is supposed to represent an unit of functionality. For example, if you implement a list type / class, you might want to put the class for this type and every function related to it into this file.

In python, a function is supposed to be an unit of execution, eg. a bunch of code that is supposed to run at once, on some particular data. It's hard to advise you without knowing the content of the files, but the content of every file executed in your snippet of code would probably benefit from being put into functions. The file division could be kept, or not depending on functionality.

It seems more like a "batch" script. It looks analogous to writing a bash or batch file in unix/windows to do a bunch of pre-defined things. I definitely agree that it's not really a pythonic thing to do as is written though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM