Annoying octal notation

Mensanator mensanator at
Fri Aug 21 00:18:35 CEST 2009

On Aug 20, 2:06 pm, David <71da... at> wrote:
> Hi all,
> Is there some magic to make the 2.x CPython interpreter to ignore the
> annoying octal notation?
> I'd really like 012 to be "12" and not "10".

Use 3.1:

>>> int('012')

(Just kidding! That works in 2.5 also. How are you using it where
it's coming out wrong? I can see you pulling '012' out of a text
file and want to calculate with it, but how would you use a
string without using int()? Passing it to functions that allow
string representations of numbers?)

> If I want an octal I'll use oct()!
> "Explicit is better than implicit..."
> David

More information about the Python-list mailing list