weird problem with os.chmod
Fredrik Lundh
fredrik at pythonware.com
Sat Nov 12 06:53:17 EST 2005
Mike Meyer wrote:
> Strange that int doesn't recognize the leading 0. But you can use the
> second argument to int:
>
> >>> int("0600", 16)
> 1536
> >>>
int is designed for humans, not C programmers. humans tend to view
e.g. "08" as a valid decimal number (*), not a ValueError.
to get programmer behaviour, pass in 0 as the base:
>>> int("10", 0)
10
>>> int("010", 0)
8
>>> int("0x10", 0)
16
</F>
*) unless you're living in sweden, in which case "08" is quite often used
as an insult.
More information about the Python-list
mailing list