title: Call a method as property or function?
body: <p>Is it possible to have a method and call it as either function or property?</p>
  
  <pre><code>def Foo:
    def bar(self,x=1,y=2):
      return x+y
  
  foo=Foo()
  foo.bar #should return 3
  foo.bar(4,5) #should return 9
  </code></pre>
  
  <p>It seems to be impossible, because:</p>
  
  <ul>
  <li>foo.bar will call <code>__getattribute__</code>; if it's a descriptior, <code>__get__</code> will be called from within <code>__getattribute__</code>, meaning that bar() is evaluated before it's even returned to the caller</li>
  <li>if an attribute is a function, it only returns a function and <em>then</em> () is applied to that function</li>
  <li>because of that, it's impossible to detect in <code>__getattribute__</code> if caller is calling a property or function</li>
  <li>hence, dual behaviour is not possible</li>
  </ul>
  
  <p>What I hopped to implement is something like (pseudocode):</p>
  
  <pre><code>def __getattribute__():
     if len(args)&gt;1: return function
     else: return property
  </code></pre>
  
  <p>But because args are not passed to <code>__getattribute__</code> or <code>__get__</code>, I don't know where and how to switch between property and function.</p>