title: Function templates in python
body: <p>I would like to know how would I use similar code to <strong>template &lt; typename T></strong> in python, as it is used in the C++ code example:</p>
  
  <pre><code>template &lt;typename T&gt;
  unsigned int counting_bit(unsigned int v){
     v = v - ((v &gt;&gt; 1) &amp; (T)~(T)0/3);                           // temp
     v = (v &amp; (T)~(T)0/15*3) + ((v &gt;&gt; 2) &amp; (T)~(T)0/15*3);      // temp
     v = (v + (v &gt;&gt; 4)) &amp; (T)~(T)0/255*15;                      // temp
     return v;
  }
  </code></pre>
  
  <p>How would I typecast objects with variable typename in python the same way as it is mentioned in C++?</p>