Quote:I'm not sure I understand what you want here. Putting code in a if __name__=="__main__": section is what you do when you don't want it to be run on import.It is "possible", but I´d like to avoid run the script while import again, to save time/performance. This stuff I`m working on will get quite big the next months..
If you want it to be run on import, don't put it in such a section. Is that possible?
My prefered way would be:
Load via ImportScript
Process data with other script
(do some other stuff)
Process imported data with a 3rd script (without reloading the .csv, because this is slow)
I tried another example:
example_import_csv
import pandas as pd global df if __name__=="__main__": df = pd.DataFrame([3, 2, 1])
example_plot
from example_import_csv import df df2 = df #generate a second dataFrameit works perfectly, but only if I do NOT use if __name__=="__main__":
If I do, this error occurrs:
Error:ImportError: cannot import name 'df' from 'example_import_csv' (U:\031_Python\030_eigene_Scripte\example_import_csv.py)
So, to make my question more precise: Is there a way to NOT let "example_import_csv" run during the import at example_plot (e.g. with if __name__=="__main__":), AND still use the variable df?Thank you for helping!!
