newsgroups at jhrothjr.com
Sat Jul 24 14:31:08 CEST 2004
"Dan Bishop" <danb_83 at yahoo.com> wrote in message
news:ad052e5c.0407231818.7b02d542 at posting.google.com...
> 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
> > interpreted.
> > 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
> > wrong:
> > 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.
I thoroughly agree. However, that's simply one of the side
effects of using the C library for a lot of stuff.
More information about the Python-list