title: Efficient way of having a function only execute once in a loop
body: <p>At the moment, I'm doing stuff like the following, which is getting tedious:</p>
  
  <pre><code>run_once = 0
  while 1:
      if run_once == 0:
          myFunction()
          run_once = 1:
  </code></pre>
  
  <p>I'm guessing there is some more accepted way of handling this stuff?</p>
  
  <p>What I'm looking for is having a function execute once, on demand. For example, at the press of a certain button. It is an interactive app which has a lot of user controlled switches. Having a junk variable for every switch, just for keeping track of whether it has been run or not, seemed kind of inefficient.</p>