[Python-3000] Fwd: Re: Fwd: Re: Fwd: Re: Octal

Georg Brandl g.brandl at gmx.net
Sat Mar 17 09:57:43 CET 2007


Patrick Maupin schrieb:
> On 3/16/07, Guido van Rossum <guido at python.org> wrote:
>> Cool. Then I'll support your support for 0o, and only using lowercase
>> 0b, 0o, 0x. Maybe that'll settle the discussion about this bikeshed's
>> color. I'm also in favor of only using lowercase j for complex and
>> lowercase r for raw strings. (u will disappear with the Unicode/str
>> unification.)
> 
> In general, I support this, and weary of discussing and documenting
> the exact shade of battleship grey we have decided upon.
> 
> However, I need to ask about one blue racing stripe along the left-hand side :)
> 
> Hexadecimal numbers traditionally support upper- and lower-case
> display, chosen by the case of the 'x' character.  Python supports
> this both for input and display, and probably needs to continue to
> support the option of upper or lowercase hex for display.
> 
> I think perhaps it should be supported for input, as well, both to
> have symmetry with the display, and to allow for easy cut and paste
> (and eval() and int(s, 0)) of hexadecimal numbers from other sources.
> 
> Obviously, we cannot support this easy eval() or int(s, 0) for octal
> in the future, but arguably, there are a lot more hexadecimal numbers
> of either case "in the wild" than there are octal numbers.
> 
> I understand that the proposal is to allow 0xabc or 0xABC, but not
> allow 0Xabc or 0XABC, but one of the strengths of Python is that I can
> easily parse files containing numerical data from almost arbitrary
> sources, and this may be a case where "practicality beats purity"
> should rule, although it may also be an easy counterargument that I/O
> symmetry is not really that important, and that one can easily write
> "x = x.replace('0X', '0x')" for the example I have given.  Your call.

Please no gratuitous breakage!

I'd continue to allow 0Xabc and 0xABC and 0xabc and 0XABC. Do a Google
codesearch, and you'll find them in Python code as well as data files.
I'd not allow 0O or 0B prefixes.
I'd not allow an "R" string prefix -- I've never seen anyone use it.

Georg



More information about the Python-3000 mailing list