Python Forum
How can I start a python program out of a python program?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I start a python program out of a python program?
#1
How can I start a python program out of a python program, or copy files?
Reply
#2
Quote:or copy files?
Is this your real goal?
If so, there's a better solution than running another program
Reply
#3
its just a or
I allso want to now this: "How can I start a python program out of a python program?"
Reply
#4
  • You can import it. And then just run what you need from the imported module
    import mymodule
    
    mymodule.myfunction()
  • That being said, there are other ways, one (which is unsafe) is to use exec:
    execfile('mymodule.py')
  • You can spawn it using os (again not recommended):
    import os
    
    os.system('python mymodule.py')
  • And finally, save the best for last, use subprocess
    import subprocess
    runproc = subprocess.run([python mymodule.py])
    
    
    # if you need to capture output of mymodule use:
    runproc = subprocess.run([python mymodule.py]
        stdout=subprocess.PIPE,
    )
    
    results = runproc()
    print(results)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Coin Flip Program Warbit 10 12,566 Apr-16-2025, 01:17 PM
Last Post: menator01
  Help with dice roll program kraco 7 4,101 Nov-26-2024, 03:07 AM
Last Post: menator01
  Pipe traceback to a C program Alexandros 0 701 Oct-22-2024, 12:32 PM
Last Post: Alexandros
  Trying to Make Steganography Program Work For All Payload Types Stegosaurus 0 1,127 Sep-26-2024, 12:43 PM
Last Post: Stegosaurus
  need help writing a program to run VIN numbers, any advice? Jhins007 4 1,167 Aug-23-2024, 08:06 AM
Last Post: DeaD_EyE
  problem program runs in a loop jasserin 0 802 May-18-2024, 03:07 PM
Last Post: jasserin
  Schedule exit a program at a specific time 4 am every day. chubbychub 3 1,467 May-17-2024, 03:45 PM
Last Post: chubbychub
  kill python execution program lebossejames 0 784 Mar-16-2024, 11:16 AM
Last Post: lebossejames
  Unexpected termination of program when using JDBC drivers in python with jaydebeapi skarface19 2 2,024 Feb-17-2024, 12:01 PM
Last Post: skarface19
  Basic Coding Question: Exit Program Command? RockBlok 3 1,790 Nov-19-2023, 06:31 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020