开发者

How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe?

开发者 https://www.devze.com 2022-12-15 01:40 出处:网络
How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe? By large I mean over 100. Each script is a simple acceptance test for a service application and will

How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe? By large I mean over 100. Each script is a simple acceptance test for a service application and will run very quickly.

The simplest approach I can think of is a cmd file that loops through the *.py files calling:

ipy <filename1>.py
ipy <filename2>.py
...

However each script would then incur the overhead of starting ipy.exe. Some research on http://python.org turned up the exec function开发者_JAVA百科. A master python script that loops through each of the test script files and calls exec with the file contents looks like a viable alternative - is this a reasonable approach?

Edit: this was far simpler than I realized - see 2 lines below. Python is awesome!

for filename in list_of_files:
    exec(open(filename).read())


Try execfile.

0

精彩评论

暂无评论...
验证码 换一张
取 消