Hey there,

The `int()` function allows to specify a base to convert from, for example:

>>> int("foo", 26)
10788

Which is documented as:

> The base defaults to 10.  Valid bases are 0 and 2-36.

For other common bases functions exist in the base64 module in stdlib.

I often need other bases, or bases with custom alphabets. Doing so involves
a bit of code every time that I think could be generalized so I'd like to 
propose
an `int.to_base()`, and `int.from_base`. These would not supercede or replace 
any
current possibilities but extend and simplify current possibilities.

The signature(s) I had in mind for now are akin to:

> int.from_base(x, alphabet, padding_character)

and 

> int.to_base(alphabet, padding_character)

Has any discussion on this been had previously (I searched around a bit), and if
not would this make a decent PEP?

Regards,

Simon
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/36CNAKMLEPKMTESFK3SMDNDLKNZVXQQE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to