<div dir="ltr">Btw, when you say translation table, do you mean just a string? Because a translation table would need to be continuous from 0 to the base so a real dicitionary-esque table may be overkill. The only advantage of a table might be to convert certain digits into multiple bytes (some sort of ad-hoc unicode use case?).<div>
<br></div><div>--yuv<br><br><div class="gmail_quote">On Sun, Sep 13, 2009 at 9:06 PM, Mark Dickinson <span dir="ltr"><<a href="mailto:dickinsm@gmail.com">dickinsm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Fri, Sep 11, 2009 at 4:16 PM, Yuvgoog Greenle <<a href="mailto:ubershmekel@gmail.com">ubershmekel@gmail.com</a>> wrote:<br>
> Does anybody have any more use cases, ideas or suggestions? I'm getting the<br>
> feeling this suggestion is +0 to most people and +1 for the rest. I'm pretty<br>
> new to these mailing lists so does that mean a yes or a no?<br>
<br>
</div>Just out of curiosity, I did a Google code search[*] for uses of the<br>
inverse operation: int(<some_string> ,n).  I found a good handful of<br>
uses of int(s, 36), almost all apparently to do with turning integers<br>
into suitable id strings;  there was also evidence that people have<br>
implemented the reverse 'integer -> base 36 string' conversion at<br>
least twice.  I found no meaningful uses of any bases other than<br>
2, 8, 10, 16, and 36.  So the main use case seems to be<br>
serialization and deserialization of integers into some 'suitably nice'<br>
alphabet, and that alphabet is likely to be application-dependent.<br>
<br>
-0 for int.to_base(n) (2 <= n <= 36) or equivalent functionality in the core.<br>
<br>
+0 for a pair of library functions converting to and from base n, with<br>
explicitly given translation table.  I agree with MRAB that an implicit<br>
digit set should only be allowed for 2 <= base <= 36, if at all.<br>
<br>
By the way, _PyLong_Format in Objects/longobject.c *does* contain<br>
code for general integer -> base b conversions, 2 <= b <= 36,<br>
but that code is currently unused (as far as I can tell).<br>
<br>
Mark<br>
<br>
[*] <a href="http://www.google.com/codesearch?hl=en&lr=&q=%5CWint%5Cs*%5C%28.*%5C%2C%5Cs*36%5Cs*%5C%29+lang%3Apython&sbtn=Search" target="_blank">http://www.google.com/codesearch?hl=en&lr=&q=%5CWint%5Cs*%5C%28.*%5C%2C%5Cs*36%5Cs*%5C%29+lang%3Apython&sbtn=Search</a><br>

</blockquote></div><br></div></div>