title: Python: Correct use of Click with __main__ and __init__
body: <p>I have been playing around with the <a href="http://click.pocoo.org/5/" rel="noreferrer">Click package</a> and I can't get the following snippit of code to work properly. </p>
  
  <pre><code>import numpy as np
  import click
  
  @click.command()
  @click.option('--get_print', default = True)
  
  class CustomClass():
  
       def __init__(s, get_print):
  
          s.data = np.random.normal(0, 1, 10)
          s.get_print = get_print
  
          if s.get_print:
              print("get_print =", s.get_print)
  
       def print_mean(s):
  
          print("Printing mean:")
  
          mean_ = np.mean(s.data)
  
          if s.get_print:
  
              print(mean_)
  
  if __name__ == '__main__':
      CustomClass().print_mean()
  </code></pre>
  
  <p>It seems that the <code>print_mean</code> function never gets called. If I comment out the @Click decorator, and manually set <code>get_print=True</code>, the <code>print_mean</code> method gets called just fine.</p>
  
  <p>My suspicion is that @Click somehow sets <code>__main__</code> and so when I do <code>if __name__ == '__main__'</code> it just calls Click again - but perhaps I'm wrong? </p>
  
  <p>In either case, what is the <em>correct</em> way of using Click, when you want the <code>__init__</code> method to inherit all the options, and <code>if __name__ == '__main__'</code>to actually be able to call functions inside the class, where the <code>__init__</code> is defined?</p>