[Python-Dev] Octal literals

Adam Olsen rhamph at gmail.com
Wed Feb 1 16:32:49 CET 2006


On 2/1/06, Gustavo J. A. M. Carneiro <gjc at inescporto.pt> wrote:
> On Tue, 2006-01-31 at 17:17 -0500, Andrew Koenig wrote:
> > I am personally partial to allowing an optional radix (in decimal) followed
> > by the letter r at the beginning of a literal, so 19, 8r23, and 16r13 would
> > all represent the same value.
>
>   For me, adding the radix to the right instead of left looks nicer:
> 23r8, 13r16, etc., since a radix is almost like a unit, and units are
> always to the right.  Plus, we already use suffix characters to the
> right, like 10L.  And I seem to recall an old assembler (a z80
> assembler, IIRC :P) that used a syntax like 10h and 11b for hex an bin
> radix.

ffr16  #16rff or 255
Iamadeadparrotr36 # 36rIamadeadparrot or 3120788520272999375597

Suffix syntax for bases higher than 10 is ambiguous with variable
names.  Prefix syntax is not.

--
Adam Olsen, aka Rhamphoryncus


More information about the Python-Dev mailing list