[Python-ideas] Different bases format specification
MRAB
python at mrabarnett.plus.com
Sat Dec 3 02:26:30 CET 2011
On 03/12/2011 00:12, T.B. wrote:
> I will start by stating that it's not my original idea, but taken from
> Erlang. See Erlang's io:format documentation here:
> http://www.erlang.org/doc/man/io.html#format-1 and notice the 'B'
> control sequence.
>
> I would like to have an easy built-in way to print integers in different
> bases (radices). There are so many half baked solutions out there:
> http://bugs.python.org/issue6783
> http://stackoverflow.com/questions/2267362/convert-integer-to-a-string-in-a-given-numeric-base-in-python
> http://stackoverflow.com/questions/2063425/python-elegant-inverse-function-of-intstring-base
> http://code.activestate.com/recipes/65212/
>
> I suggest using the precision field in the format specification for
> integers for that.
[snip]
I think that the precision field should be used only for the precision
and that sometimes using it for something completely different is a bad
idea.
More information about the Python-ideas
mailing list