title: Is there a quick Python function for turning numbers into different bases?
body: <p>I'm writing a code to check how many times a number is a palindrome in bases 2-10. Is there a python function for converting numbers into different bases?</p>
  
  <p>I have already tried manually creating a function, but it is too slow.</p>
  
  <pre class="lang-py prettyprint-override"><code>baseChars="0123456789"
  def toBase(n, b): 
      return "0" if not n else toBase(n//b, b).lstrip("0") + baseChars[n%b]
  </code></pre>
  
  <p>I expect the toBase function to return the number expressed in all bases from 2-10. I would like to avoid NumPy</p>