[Python-3000] Octal

Chris Rebert cvrebert at gmail.com
Wed Mar 14 07:17:15 CET 2007


I agree that octal should still have a syntax. However, as you say, 0o 
doesn't jump out as much typographically. And I'm wary of adding 
arbitrary base literals to the language. It sounds like unnecessary 
complexity, though a standard library function to convert arbitrary base 
representations of ints to ints might be useful.
At any rate, I'd like to propose the octal syntax:

     0c123

I like this because "0c" looks like the start of the word "octal", and, 
as with your suggestion, the 0[character-here] prefix makes for a nice 
symmetry with "0x" for hex.

- Chris Rebert


Greg Ewing wrote:
> Josiah Carlson wrote:
> 
>> Do we deprecate it followed by a later removal (so as to "resist the
>> temptation to guess")?  If so, sounds good to me (I've never had a use
>> for octal literals). 
> 
> I think that *some* syntax should be provided for octal
> literals. They're useful when you're translating constants
> from a C header file that are expressed in octal. I'd
> suggest
> 
>    0o123
> 
> except that the lower case 'o' might be a bit hard
> to spot. :-(
> 
> Maybe something more general could be used to
> indicate a number base, such as
> 
>     1101(2)     # binary
>     1234(8)     # octal
>     1c3a(16)    # hexadecimal
>     12g7(35)    # why stop at 16?
> 
> Since calling a built-in integer never makes sense,
> this would be unambiguous.
> 
>  > Making them decimal instead, I think, would be a
>  > mistake.
> 
> Perhaps an all-digits literal with a leading zero
> should be disallowed altogether. That ought to
> prevent any accidents.
> 
> --
> Greg
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/cvrebert%40gmail.com
> 


More information about the Python-3000 mailing list