I have two scripts, first.py and second.py. I want to send variables of first to second and variables of second to first. But it shows an error. Can any one help me please?
first.py
import second
a=10
print second.b
second.py
import first
b=15
print first.a
The error
AttributeError: 'module' object has no attribute 'b'
secondinfirst.py, the first thing that happens isfirstis imported tosecond. Then,firstis read, skipping overimport secondsince that's ready happened and Python won't import the same thing twice (otherwise you'd get an infinite loop of imports between the two files). Then the linea=10is read, and finallyprint second.b. The issue is thatsecond.pyhasn't had time to read down to the bottom because it tried toimport firstfirst, and so it hasn't assignedbby the timeprint second.bis called.