Total noob here. There are two python files in this example. The first is cloned from github, the second is my own. The first is called city_data.py. Mine is called analyze.py. Within the city_data.py code there is a class with a prompt with many defined functions within the class. In my analyze.py file I want to run a specific function within the class. I got the function to run (table output) but when I try to recall variables from the file it just says "NameError: name 'pop_dens' is not defined". Is there a way to recall the variable pop_dens from my file while running the function on the imported file?
city_data.py
class city_stats():
prompt = '> '
def table_output(self, arg):
pop_dens = SingleTable(volume,'city')
...
print(table)
...
analyze.py
from city_data import city_data
analyze = city_stats()
density_output = analyze.table_output("Chicago")
print(pop_dens)
run analyze.py
table outputs successfully
"NameError: name 'pop_dens' is not defined"