title: How to enforce automatic parameter casting in function definitions?
body: <p>Consider this example of a function (and its use) that receives one parameter which is only meaningful as <code>int</code>:</p>
  
  <pre><code>def fun(index):
      index = int(index)
      # do something with index
  
  def main():
      print fun(1e6)
  </code></pre>
  
  <p>I find that I keep repeating this pattern on several functions that deal with integers since it ensures that I really receive some integer number (note that <code>1e6</code> is a floating point instance).</p>
  
  <p>This is a bit cumbersome and if forgotten once it could produce problems (there <em>is</em> code that reacts differently to floating-point/integer/string/... values). So could this be somehow encoded in the function signature?</p>
  
  <p>E.g. something along the lines of this pseudo-code:</p>
  
  <pre><code>def fun(int index):
      # do something with index
  </code></pre>