Page 1 of 1

Pass variable script problem

Posted: Wed Dec 26, 2018 6:08 am
by Faruk
Hello guys. I write two python code and I can pass variable two scrpit but I have some problem. My scrpits this:

script1.py

Code: Select all

x='a'
import script2
script2

Code: Select all

import script1
import time

print "second script start"
print script1.x
print "secon script end"
When I ran script2.py result this:

Code: Select all

 second script start
 a
 second script end
 second script start
 a
 second script end
Why script2.py return result twice. Actually my main purpose make control to script that run GUI program and restart it (if GUI program has freeze). How can i fix twice run problem.

Re: Pass variable script problem

Posted: Wed Dec 26, 2018 9:52 am
by OutoftheBOTS
well when u import script1 then it imports script2 so it runs twice. Just simple remove import script2 from script1

Re: Pass variable script problem

Posted: Wed Dec 26, 2018 10:21 am
by Faruk
Thanks for your reply. It is good work :)

Re: Pass variable script problem

Posted: Wed Dec 26, 2018 10:41 am
by Faruk
Additionally. I want check my GUI program for this way. I working for take variable from my GUI program. If I could not take any output reset my rpi. But if the GUI is running I can't taking output but if I close GUI window my second script give return value. Is it fixable thing?