On 2007-10-17, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Ixiaus a écrit : >> val = 00110 >> >> as the integer 72 instead of returning 00110, why does Python >> do that? > > Literal integers starting with '0' (zero) are treated as octal. > It's a pretty common convention (like 0x for hexa). FWIW, PHP > does just the same thing. > >> (and how can I get around it?) > > You can't. Python has no literal notation for binary integers > so far. Literal notation for binary ints is not a common > feature anyway.
You can obtain a practical workaround using the int built-in function. >>> int('110', 2) 6 -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list