title: Only let function be called as a method in Python
body: <p>Say I'm writing a module, MyPyLib, that uses another built-in module. From the built-in module, I import a class, Foo. I then define this function, bar:</p>
  
  <pre><code>def bar(self):
      return self
  </code></pre>
  
  <p>This function is written to be a method of the Foo class and I can make it behave properly with <code>setattr(Foo,'bar', bar)</code>. Then <code>Foo.bar()</code> will work as intended. However, anyone who imports MyPyLib can also call <code>bar</code> as its own function. Is there any way to limit this function so that <code>Foo.bar()</code> works, but <code>bar(arg)</code> doesn't?</p>