Is this a bug in int()?

Fredrik Lundh fredrik at pythonware.com
Thu Dec 20 16:44:47 EST 2007


MartinRinehart at gmail.com wrote:

>>>> int('0x', 16)
> 0
> 
> I'm working on a tokenizer and I'm thinking about returning a
> MALFORMED_NUMBER token (1.2E, .5E+)

Somewhat surprisingly, "0x" is a valid integer literal in Python:

 >>> 0x
0

</F>




More information about the Python-list mailing list