By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,699 Members | 1,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,699 IT Pros & Developers. It's quick & easy.

How to initialize a variable only one time when program starts

P: 2
For example I have a button and I would like to use it to turn something on and off with the same button.
So I thougt, I would use some wariable which woild keep track of the state, but I can't seem to make it work.
I would need to initialize X to value 0, but that initialization should happen only once when the program starts.

x = 0 -> (this part should happen only when program is started)

if x == 0:
turn switch on
x = 1
turn switch off
x = 0
Sep 2 '13 #1
Share this Question
Share on Google+
1 Reply

P: 2
I found another solution.
I used a ToggleButton and .get_active() method
to get the state of a button.
Sep 2 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.