python import list from py file 1

python import list from py file

# In first .py file
mylist = ['this', 'that', 'theother']

# In second file
from variables import mylist

Here is what the above code is Doing:
1. It imports the variables module.
2. It looks for a variable named mylist in the variables module.
3. It creates a reference to that variable in the current scope.

Similar Posts