The Python case seems global, so the modules modifying it will influence each other.
Although, of course, there are many third-party modules, is there a way to use the standard Python library for a random number local to the context.
(without using random.get/setstate , which can be problematic when mixing code from different modules).
Sort of...
r = random.context(seed=42) number = r.randint(10, 20)
Where each module can use its own random context.
source share