Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Pass variable script problem

Wed Dec 26, 2018 6:08 am

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.

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Pass variable script problem

Wed Dec 26, 2018 9:52 am

well when u import script1 then it imports script2 so it runs twice. Just simple remove import script2 from script1

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: Pass variable script problem

Wed Dec 26, 2018 10:21 am

Thanks for your reply. It is good work :)

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: Pass variable script problem

Wed Dec 26, 2018 10:41 am

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?

Return to “Python”