Utilize Modules

Hi everyone, I am new in python and I need some help to import a module that I created.

My created module (Generation) consists in generate random variables of physical characteristics of pedestrians. The module works well. Nevertheless, when I import it to the main code that is subdivided in FORs, the Variables generated in the module do not change in each increment. What should I do to circumvent this problem?

The following statement indicate the structure of the code:

for i in range (1000):
for j in range (2000):
import Generation (I need different variables for each increment, but it generates the same)


A module is only ever executed once. The first time it’s imported, the code is run. Any other imports after that give the existing module. What you should do is move the code in that module into a function, so you can call it multiple times. How it is right now, you couldn’t pass in i and j anyway.