danb_83 at yahoo.com
Sat Jul 24 04:18:00 CEST 2004
Willem Broekema <news at pastelhorn.com> wrote in message news:<qqWdnThBC-nI4ZzcRVn-pQ at speakeasy.net>...
> To me, it seems there are some irregularities in how literal numbers are
> As you know, Python allows integer literals in three bases:
> Now for complex integers:
> "11j" -> 11j
> "011j" -> 11j <--
> "0x11j" -> syntax error <--
The same occurs with real floating-point literals
"11." -> 11.0
"011." -> 11.0
"0x11." -> syntax error
> I expected "011j" to be read as an octal complex, resulting in 9j,
> and "0x11j" to be read as a hexadecimal complex, resulting in 17j.
> Currently, "011j" and "011 * 1j" are different, and that strikes me as
> So "011.3" and "011.3j" are read as in base 10. Wouldn't a syntax error
> be more appropriate, as it is an attempt to read a floating point in
> octal, which is unsupported?
I think the best solution would be to use some other syntax for octal
literals. Even without the float and complex weirdness, it's not at
all obvious (except to C programmers) that 011 != 11.
More information about the Python-list