title: Circular shift of a bit in python (equivalent of Fortran's ISHFTC)
body: <p>I want to achieve the equivalent of the ISHFTC function in Fortran using python.
  What is the best way to do this?</p>
  <p>For example,</p>
  <pre><code>x = '0100110'
  s = int(x, 2)
  s_shifted = ISHFTC(s,1,7) #shifts to left by 1
  #binary representation of s_shifted should be 1001100
  </code></pre>
  <p>My attempt based on <a href="https://stackoverflow.com/questions/13289397/circular-shift-in-c">Circular shift in c</a></p>
  <pre><code>def ISHFTC(n, d,N):  
      return (n &lt;&lt; d)|(n &gt;&gt; (N - d)) 
  </code></pre>
  <p>However, this does not do what I want. Example,</p>
  <pre><code>ISHFTC(57,1,6) #57 is '111001'
  </code></pre>
  <p>gives 115 which is '1110011' whereas I want '110011'</p>