title: Writing a class inside a function in Python
body: <p>I am trying to write a class inside a function... something like the following:</p>
  <pre><code>def func(**args):
     class BindArgs(object):
         foo = args['foo']
         print 'foo is ', foo
         def __init__(self,args):
            print &quot; hello, I am here&quot;
  
  f = func(foo=2)
  </code></pre>
  <p>I was hoping that print will be executed.. but the <strong>init</strong> block is not being executed... though print 'foo is ' stub runs... What am I missing?</p>
  <p>I am trying to understand, how does this module works (<a href="https://github.com/tweepy/tweepy/blob/master/tweepy/binder.py" rel="nofollow noreferrer">https://github.com/tweepy/tweepy/blob/master/tweepy/binder.py</a>)?</p>