Python: Start a new process replacing the current process
Python Operating System Services: Exercise-18 with Solution
Write a Python program to start a new process replacing the current process.
Sample Solution:
Python Code :
main.py:
import os
import sys
program ="python"
arguments = ["hello.py"]
print(os.execvp(program, (program,) + tuple(arguments)))
print("Goodbye")
hello.py:
print("Operating System Services Exercises-18")
Sample Output:
Operating System Services Exercises-18
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to run an operating system command using the os module.
Next: Python Operating System Services Home page.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
Performs right-to-left function composition.
Example:
from functools import reduce def tips_compose(*fns): return reduce(lambda f, g: lambda *args: f(g(*args)), fns) add6 = lambda x: x + 6 multiply = lambda x, y: x * y multiply_and_add_6 = tips_compose(add6, multiply) print(multiply_and_add_6(10, 3))
Output:
36
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework