# Accelerator.py revs_pc = 999 if __name__ == '__main__': print(f"Revs = {revs_pc}")
# bar.py import Accelerator import math def foo(arg): value = math.factorial(arg) + Accelerator.revs_pc return value if __name__ == '__main__': print(foo(10))
Output:3629799
So it's a good practice to use if __name__ == '__main__'
,then dos code after that do not execute when import it.Have to call
Accelerator.revs_pc
to get 999.Also look that i use
f-string
to avoid the not so nice way print("Revs = " + str(int(revsPC)))
.