Let’s assume I have the following file structure:
data.py
foo = []
bar = []
abc = "def"
core.py
import data
# do something here #
# a = ...
print a
# ['foo', 'bar', 'abc']
I need to get all the variables defined in data.py file. How can I achieve that? I could use dir(), but it returns all the attributes of the module including __name__ and so on.
Is usually the recipe for doing this, but it begs the question.
Why?