Annoying octal notation

James Harris james.harris.1 at googlemail.com
Fri Aug 21 19:52:29 EDT 2009


On 21 Aug, 22:18, MRAB <pyt... at mrabarnett.plus.com> wrote:
> Piet van Oostrum wrote:
> >>>>>> Derek Martin <c... at pizzashack.org> (DM) wrote:
>
> >> DM> I fail to see how 0O012, or even 0o012 is more intelligible than 012.
> >> DM> The latter reads like a typo, and the former is virtually
> >> DM> indistinguishable from 00012, O0012, or many other combinations that
> >> DM> someone might accidentally type (or intentionally type, having to do
> >> DM> this in dozens of other programming languages).  
>
> > You're right. Either hexadecimal should have been 0h or octal should
> > have been 0t :=)
>
> I have seen the use of Q/q instead in order to make it clearer. I still
> prefer Smalltalk's 16rFF and 8r377.

Two interesting options. In a project I have on I have also considered
using 0q as indicating octal. I maybe saw it used once somewhere else
but I have no idea where. 0t was a second choice and 0c third choice
(the other letters of oct). 0o should NOT be used for obvious reasons.

So you are saying that Smalltalk has <base in decimal>r<number> where
r is presumably for radix? That's maybe best of all. It preserves the
syntactic requirement of starting a number with a digit and seems to
have greatest flexibility. Not sure how good it looks but it's
certainly not bad.

  0xff & 0x0e | 0b1101
  16rff & 16r0e | 2r1101

Hmm. Maybe a symbol would be better than a letter.

James



More information about the Python-list mailing list