# Python variable scope between modules

I have some serious lack of knowledge on how variables in python work. My code is spread between multiple modules and I will try to write only the more important stuff:

```#price.py

import math

LAMBDA = 0.03
EPSILON = 0.97
SCALING_PARAMETER = 10  # Used for initializing the propensities
FEED_IN_TARIFF = 8.50
UTILITY_PRICE = 33
PRICE_SET = list(range(math.floor(FEED_IN_TARIFF),
math.floor(UTILITY_PRICE) + 1))
AVERAGE_PROFIT = sum(PRICE_SET) / len(PRICE_SET)

probabilities = [1 / len(PRICE_SET)] * len(PRICE_SET)
propensities = [SCALING_PARAMETER * AVERAGE_PROFIT / len(PRICE_SET)] * len(PRICE_SET)

if p_local_sell != 0 or p_grid_sell != 0:
r_prosumer = p_local_sell * cl_price + p_grid_sell * FEED_IN_TARIFF
r_consumer = p_local_buy * abs(FEED_IN_TARIFF - cl_price)

prop_i = PRICE_SET.index(cl_price)

if p_local_sell != 0 or p_grid_sell != 0:
propensities[prop_i] = (1 - LAMBDA) * propensities[prop_i] + r_prosumer * (1 - EPSILON)
propensities[prop_i] = (1 - LAMBDA) * propensities[prop_i] + r_consumer * (1 - EPSILON)

for i in range(0, prop_i):
propensities[i] = (1 - LAMBDA) * propensities[i] + (propensities[i] * EPSILON) / (len(PRICE_SET) - 1)
for i in range(prop_i + 1, len(propensities)):
propensities[i] = (1 - LAMBDA) * propensities[i] + (propensities[i] * EPSILON) / (len(PRICE_SET) - 1)

for i in range(0, len(probabilities)):
probabilities[i] = propensities[i] / sum(propensities)

#handler.py

import price
import numpy as np

def update_data(data):
# some unimportant calculations

def get_price():
# some unimportant calculations
price = np.random.choice(price.PRICE_SET,1,p=price.probabilities)
return int(price)
```

The code is in docker containers and when I execute the `update_data(data)` function, and `docker exec -it "container_name" python3 -c "import price; print(price.propensities)"` it returns always the initial ones.

1. Am I checking the values wrong, when I try to print the values within the containers?
2. Do the variables have to be global for this to work?
3. Is my understanding so poor, that what I am trying to do is not possible and I would be better off when I write the values into an external file and read them from there?

Your `docker exec` command starts a new Python process, imports the module, and then prints the value. Of course the value is the default, because you just imported the module and did nothing with it in that Python process.
If you’re only interested in certain values, and these change only at well-defined times, you could let the process write the values to a file every time they change, and then read the file from `docker exec`. But then you’d still have to guard against the case that the file is being overwritten while you’re reading it.