Sometimes a need to get variables into your Python code, without hard-coding them into the program itself will arise.
Here is how it can handled.
sudo apt install python3-decouple -y
Add this into your py program’s import lines:
from decouple import config
Next, you need to create .env file and insert variables into it.
touch .env
nano .env
SOME_VAR=some_value
Then in your code, you would refer to your variable like this:
some_var=config(“SOME_VAR”)