Tag Archives: python variables

Python with decoupled variables

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


Then in your code, you would refer to your variable like this: