Let's say I run
from variables import b
and variables.py
is as follows:
a = [i ** i for i in range(10000)] # or any other computation that takes a long time
b = 1
Is there a way to import b
without computing a
?
I was thinking that I could add an if statement like this:
if (variable_being_imported() == 'b'):
b = 1
else:
a = [i ** i for i in range(10000)]
I know I can define functions and run the functions after importing them, but is there a way without defining functions?