[Python-3000] String literal representation of integers (octal/binary discussion)

Guido van Rossum guido at python.org
Mon Mar 19 03:36:58 CET 2007


On 3/18/07, Thomas Wouters <thomas at python.org> wrote:
>
>
> On 3/18/07, Patrick Maupin <pmaupin at gmail.com > wrote:
> > the treatment of string literal representations of integers
>
> I don't think this is the right term. It's certainly confusing, considering
> "string literals" are the stuff in quotes. A less confusing name is just
> 'integer literals'.

Right. This is how the Python reference manual uses the term.
"Literals" are all notations for values; e.g. string literals, numeric
literals. (We don't talk of list or dict literals since they can
contain arbitrary expressions.)

> >     - There is a strong desire for binary support in the language.
>
> I have yet to see this 'strong desire'. I've seen people remark that they
> think it'd be nicely symmetric, but requests for actual usecases have always
> gotten low responses, as far as I remember. I've done quite a bit of
> bitfiddling with Python, with the struct module or with hexadecimals and
> bitwise operations, and in none of those cases would a binary literal have
> been helpful; they're way too verbose and impossible to get right/debug.

Well, *I* have seen the strong desire -- not in myself, but I have
seen it. It's a done deal. 0b for binary is in.

> > But the Python community has its share of minimalists (each with
> > his own idea of the proper subset), so, for example, Mattias
> > Engdegård wrote: "only decimal, hex and binary constants are
> > of general use at all" while Thomas Wouters opined that octal
> > and hexadecimal should remain but binary was only for misguided
> > students doing their homework.
>
> This strikes me as a rather snide and childish paragraph [...]

Patrick, please remove specific names from the PEP.

> > So, in general, humans communicate "normal" (non-computer)
> > numerical information either via names (AM, PM, January, ...)
> > or via use of decimal notation.  Obviously, names are
> > seldom used for large sets of items, so decimal is used for
> > everything else.  There are studies which attempt to explain
> > why this is so, typically reaching the expected conclusion
> > that the Arabic numeral system is well-suited to human
> > cognition. [3]_
>
> I'm not sure why all this matters to the PEP, really. Do we really have to
> justify having decimal, hexadecimal and octal literals? It's _way_ oversized
> if you ask me :)

Octal does need to be justified, since some people argued to remove
it. I guess binary needs to be justified because Thomas doesn't see
the need. :-)

> --
> Thomas Wouters <thomas at python.org>

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


More information about the Python-3000 mailing list