Annoying octal notation

Simon Forman sajmikins at gmail.com
Thu Aug 20 16:37:33 EDT 2009


On Aug 20, 3:06 pm, David <71da... at libero.it> wrote:
> Hi all,
>
> Is there some magic to make the 2.x CPython interpreter to ignore the
> annoying octal notation?

No.  You would have to modify and recompile the interpreter. This is
not exactly trivial, see "How to Change Python's Grammar"
http://www.python.org/dev/peps/pep-0306/

However, see "Integer Literal Support and Syntax" http://www.python.org/dev/peps/pep-3127/

(Basically in 2.6 and onwards you can use 0oNNN notation.)

> I'd really like 012 to be "12" and not "10".
>
> If I want an octal I'll use oct()!

But that gives you a string, you're asking about literals.




More information about the Python-list mailing list