I want to share a variable between two scripts, and in one script, there's a calculation based on the variable dynamically. My use case is aiming for separating the concern on building a website, specifically, using streamlit. But, I would like to provide a simple example to explain what I am trying to do. I would only run app.py
.
For example:
[app.py]
# get the input from the user
select = input("[Please choose A, B, or C]")
print(result)
[data.py]
# where I want to deal with data things
# such as making a query to Pandas data frame
result = df[df['choice']==select]['result'].values[0]
What I've found:
- If I import
select
andresult
to each other, it would be a circular import. - I found the multiprocessing usage, sharing the variable between two scripts, but it seems to not be capable of solving the problem.
Is it possible to share a variable dynamically or sort of concurrently between files with any library? Please advise if my title or example could've improved. Thanks.