title: IIFE in python common convention
body: <p>I was considering a similar case like this question I've asked:
  <a href="https://stackoverflow.com/questions/27792688/set-timeout-function-callback-static-variables">Set Timeout Function CallBack static variables</a></p>
  
  <p>But, in python. I have tried to do some searching but can't seem to figure out how to find it.</p>
  
  <p>I was considering if I had a scenario I needed to perform an operation in the future, and needed to wait (or a timer for example), but the operation may require data at that moment in time (when I called the function that is to be calling the callback in the future). </p>
  
  <p>In Javascript I understand there is the bind operation, or using closures.</p>
  
  <p><strong>I was wondering if people actually do this in python, and if so what are/is the common conventions regarding it?</strong></p>
  
  <p>I'm thinking of code something like this:</p>
  
  <pre><code>import threading
  import time
  x = "ABCD"
  class Typewriter(threading.Thread):
      def __init__(self):
          threading.Thread.__init__(self)
  
      def run(self):
         time.sleep(5)
         print x
  # make it type!
  def foo(q):
     q
  
  def bar():
     typer = Typewriter()
     typer.start()
  
  
  s = bar()
  foo(s)
  x = "DEF"
  </code></pre>
  
  <p>I can't really pass a value into the foo(s), (I tried foo(s(x)) and I get the same result).</p>
  
  <p>Is there something similar to python? I could say do</p>
  
  <p>foo(s(q).bind(x))</p>
  
  <p>If so what are the normal conventions? Are there more than one way to skin a cat here?</p>
  
  <p>(I know I know technically I can use x in the Typewriter class initialization and that would happen before the variable x gets changed, however I couldn't think of a better way to express the equivalent function as in the first question). My main goal here is to be able to pass in the variable to be used in the future, and not use it more or less indirectly.</p>