[Python-ideas] Add a builtin method to 'int' for base/radix conversion

Carl Johnson cmjohnson.mailinglist at gmail.com
Mon Aug 31 06:55:03 CEST 2009


Doing some testing with int, I found:

ValueError: int() base must be >= 2 and <= 36

That resolves a lot of questions (it has to be case insensitive), but
takes away ability to do the motivating use case: writing out video
ids in Base-62.

—Carl

On Sun, Aug 30, 2009 at 6:49 PM, Carl
Johnson<cmjohnson.mailinglist at gmail.com> wrote:
> How would it work for bases beyond 10? OK, so base-16 has a well known
> encoding, but what about base-100? Base-16 is case insensitive, but
> would Base-37 be case insensitive?…
>
> ISTM that the common encodings of bin, oct, and hex are already
> covered by built-in functions and for bases beyond that, you have
> decide what system to use for encoding symbols that are out of range.
> Do people really need trinary through septary that often? Is there a
> single, best-practices way of doing base-1013? Feels like YAGNI to me,
> but I could be wrong.
>
> — Carl Johnson
>



More information about the Python-ideas mailing list