Proposal: Decimal literals in Python.

Scott David Daniels Scott.Daniels at Acm.Org
Tue Jul 14 11:44:04 EDT 2009


Tim Roberts wrote:
> My favorite notation for this comes from Ada, which allows arbitrary bases
> from 2 to 16, and allows for underscores within numeric literals:
> 
>   x23_bin : constant :=  2#0001_0111#;
>   x23_oct : constant :=  8#27#;
>   x23_dec : constant := 10#23#;
>   x23_hex : constant := 16#17#;
And mine is one w/o the base 10 bias:
     .f.123 == 0x123
     .7.123 == 0o123
     .1.1101 == 0b1101
That is, .<largest allowed digit>.<digits>
-- show the base by showing base-1 in the base.
I actually built this into "OZ," an interpretter.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list