Ask Your Question
0

How to run two py files

asked 2021-06-24 09:09:46 -0500

Nan_MX96 gravatar image

How can I first run a py file to open some files and then another py file to run a task. How to run 2 py files or more.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2021-06-24 15:03:28 -0500

perolofl gravatar image

A python script can be executed by another python script with execfile. Use a main script to execute the two scripts. For example:

execfile('file1.py')
execfile('file2.py')
edit flag offensive delete link more

Comments

@jconto@perolofl I have not worked with codes, as it is possible to execute the two files py in PSS E 34. With a py I want to open several files and then make adjustments in parameters and with another py I want to execute the dynamic simulation. To save time.

Nan_MX96 gravatar imageNan_MX96 ( 2021-06-24 16:09:19 -0500 )edit

If the second py needs data from the first py (or wait to finish), then there is no saving in time. It is still a sequential process. It is the dynamic simulation itself that takes the most time in a dynamic study. Use a single file in a parallel process. Do post-processing separate.

jconto gravatar imagejconto ( 2021-06-25 08:58:33 -0500 )edit
0

answered 2021-06-24 14:01:28 -0500

jconto gravatar image

Open separate CMD windows and run pythoni in windowi. The problem arises if both python scripts need to interact between them.

Another option is to use "subprocess" or "multiprocessing" (as a 'parent') to better control multiple tasks executed by different other scripts ('child' processes)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2021-06-24 09:09:46 -0500

Seen: 239 times

Last updated: Jun 24 '21