[Python-Dev] re: %b format (no, really)

Guido van Rossum guido@digicool.com
Fri, 08 Jun 2001 12:06:19 -0400

> Prompted in part by the comment in Michael Hudson's
> python-dev summary about this discussion having died,
> I'd like to summarize:
> 1. Most people who commented felt that a base-2 format
>    would be useful, if only for teaching and debugging.
>    With regard to questions about byte order:
>    A. Integer values are printed as base-2 numbers, so
>       byte order is irrelevant.
>    B. Floating-point numbers are printed as:
>       [sign] [mantissa] [exponent]
>       The mantissa and exponent are shown according
>       to rule A.

Why bother with floats at all?  We can't print floats as hex either.
If I were doing any kind of float-representation fiddling, I'd
probably want to print it in hex anyway (I can read hex).  But as I
say, that's not for the general public.

> 2. Inventing a format for converting to arbitrary
>    bases is dubious hypergeneralization (to borrow a
>    phrase).


> 3. Implementation should mirror octal and hexadecimal
>    support, e.g. a 'bin()' function to go with 'oct()'
>    and 'hex()'.
> 4. The desirability or otherwise of a "%b" format
>    specifier has nothing to do with the relative
>    merits of any early microprocessor :-).
> If no-one has strong objections, I'll put together a
> PEP on this basis.

Go for it.  Or just submit a patch to SF -- this seems almost too
small for a PEP to me. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)