[Python-3000] String literal representation of integers (octal/binary discussion)
Jim Jewett
jimjjewett at gmail.com
Mon Mar 19 04:54:05 CET 2007
On 3/18/07, Guido van Rossum <guido at python.org> wrote:
> 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. :-)
I see literals for octal and binary as similar to raising a tuple, or
automatically unpacking one in a function call. It can be useful, but
it isn't needed very often. When it does show up, it can be confusing
*because* it is so rare.
If I were only worried about one program, I would prefer to write:
>>> oct(78) == "0o116"
rather than:
>>> from math import oct
>>> oct(78) == int("123", 8)
The preference isn't really overwhelming, though, and the use isn't
very frequent. This doesn't seem like a big enough win to justify any
extra complexity in the language.
(And no, I wouldn't add hex either, but not adding is different from removing.)
-jJ
More information about the Python-3000
mailing list