Skip to content
Advertisement

Process a function on different arguments in parallel in Python

This is my simple code where I want to run printRange() in parallel:

JavaScript

My question is different from this SO question as here, the each process is hardcoded, started and finally joined. I want to run printRange() in parallel with say 100 other printRange() worker functions. Hardcoding each time is not feasible. How could this be done?

Advertisement

Answer

Using multiprocessing

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement