Executing a second python file with one of several options at a time

Joined
Nov 4, 2025
Messages
1
Reaction score
0
Hello,

I am working on a project and I've come pretty far but the last few days I am simply banging my head against the wall with this topic. It is a PIN code system whereby a particular PIN code is assigned to a particular solenoid lock.

The main file has a function in it where it takes the user input (PIN) and checks it against the existing PINs and when a correct PIN is entered, it triggers one of the "if" statements. Along with each "if" statement that is triggered in the main file, I want to execute an external file with say, one out of four possible options (rather than having 4 separate files to execute).

To do this I am using subprocess so: subprocess.Popen(['python', 'NoidCode.py', what_to_put_here?) where "what_to_put_here?" is where I want to instruct "NoidCode.py" to run, with say option 2 (out of possible 4)

I am not passing variable data, I am just asking it to execute the file with that option or another but none at the same time. I know there are fancier ways to do this but I am looking for simplicity so there is less chance of stuff breaking further down the line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,342
Messages
2,571,407
Members
48,797
Latest member
kenne2025

Latest Threads

Top