Annoying octal notation

Derek Martin code at pizzashack.org
Mon Aug 24 13:40:24 EDT 2009


On Mon, Aug 24, 2009 at 05:03:28PM +0000, Steven D'Aprano wrote:
> On Mon, 24 Aug 2009 11:21:46 -0500, Derek Martin wrote:
> > since the old syntax is prevalent both within and without the
> > Python community, making the change is, was, and always will be a
> > bad idea.
>
> Octal syntax isn't prevalent *at all*, except in a small number of
> niche areas.

Steven, don't be obtuse.  Where octal is used in programming, the
leading zero is prevalent.  

> You've said that this change is a hardship for you, because on your 
> terminal 0 and o are hard to distinguish. Personally, I'd say that's a 
> good sign that your terminal is crappy and you should use a better one, 

The terminal I use is just fine.  Stringing together similar
characters always has the possibility of confusing the reader.  The
human mind tends to see what it expects, and fills in the gaps when it
does not.  It wouldn't matter much if I changed my terminal font,
unless I made the font big enough to be not especially useful, except
for the rather exceptional case of detecting 0o1 and similar patterns
in python code.  The suggestion is asinine, and you know it.

> but putting that aside, let's accept that. To you, for whatever reason, 
> 0o looks just like 00.

It doesn't look "just like" 00, but similar enough that you have to
pay close attention.

> Okay then. Under the current 2.x syntax, 0012 would be interpreted as 
> octal. Under the new 3.x syntax, 0o12 which looks just like 0012 also 
> would be interpreted as octal. You have argued that it might not be any 
> harder to type the extra 'o' to get an octal literal, but that it will 
> hurt readability. I quote:
> 
> "Writing 0o12 presents no hardship; but I assert, with at least some
> support from others here, that *reading* it does."
 
Let me clarify my statement.  Writing 0o12 is easy -- there is no
hardship to type the characters 0o12 (well, actually it feels a bit
cumbersome, to be honest).  Remembering to do so, however, when
virtually everwhere else one uses octal writes it 012, is not easy.
Then I stand corrected:  There is indeed hardship.

> But according to you, reading 0o12 is just like reading 0012. 0o12 under 
> the new syntax gives decimal ten, and it looks just like 0012 in the old 
> syntax, which also gives ten. So there's no difference in reading, 

But there *IS* a difference in reading, because 0o12 is not the same
as 0012, and which one you use *matters*.  In particular, it will matter 
with the adoption of Python 3.x, where the latter will be an error.
But it matters even in 2.6 because right now, you can write it either
way, and that is (I think) even more confusing...  There is also still
discussion (mentioned in the relevant PEP) about making 0012 *valid
decimal*.  That should never, ever, ever happen.

Why is it so hard for you to accept that intelligent people can
disagree with you, and that what's right for you might be bad for
others?

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090824/823479fd/attachment-0001.sig>


More information about the Python-list mailing list