On 23 Aug, 00:16, Mel <mwil...@the-wire.com> wrote: > James Harris wrote: > > I have no idea why Ada which uses the # also apparently uses it to end > > a number > > > 2#1011#, 8#7621#, 16#c26b# > > Interesting. They do it because of this example from > <http://archive.adaic.com/standards/83rat/html/ratl-02-01.html#2.1>:
Thanks for providing an explanation. > > 2#1#E8 -- an integer literal of value 256 > > where the E prefixes a power-of-2 exponent, and can't be taken as a digit of > the radix. That is to say > > 16#1#E2 > > would also equal 256, since it's 1*16**2 . Here's another suggested number literal format. First, keep the familar 0x and 0b of C and others and to add 0t for octal. (T is the third letter of octal as X is the third letter of hex.) The numbers above would be 0b1011, 0t7621, 0xc26b Second, allow an arbitrary number base by putting base and number in quotes after a zero as in 0"2:1011", 0"8:7621", 0"16:c26b" This would work for arbitrary bases and allows an exponent to be tagged on the end. It only depends on zero followed by a quote mark not being used elsewhere. Finally, although it uses a colon it doesn't take it away from being used elsewhere in the language. Another option: 0.(2:1011), 0.(8:7621), 0.(16:c26b) where the three characters "0.(" begin the sequence. Comments? Improvements? James -- http://mail.python.org/mailman/listinfo/python-list