title: Count how many arguments passed as positional
body: <p>If I have a function</p>
  <pre class="lang-py prettyprint-override"><code>def foo(x, y):
      pass
  </code></pre>
  <p>how can I tell, from inside the function, whether <code>y</code> was passed positionally or with its keyword?</p>
  <p>I'd like to have something like</p>
  <pre class="lang-py prettyprint-override"><code>def foo(x, y):
      if passed_positionally(y):
          print('y was passed positionally!')
      else:
          print('y was passed with its keyword')
  </code></pre>
  <p>so that I get</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; foo(3, 4)
  y was passed positionally
  &gt;&gt;&gt; foo(3, y=4)
  y was passed with its keyword
  </code></pre>
  <hr />
  <p>I realise I didn't originally specify this, but is it possible to do this whilst preserving type annotations? The top answer so far suggests using a decorator - however, that does not preserve the return type</p>