?Why is 0e-6 invalid?

Tim Peters tim.one at home.com
Fri Dec 22 01:03:50 CET 2000


[Norman Shelley]
> Why is 0e-6 invalid and 0*.000001 is valid?

The syntax of Python's floating-point literals is defined in the Language
Reference manual, here:

    http://www.python.org/doc/current/ref/floating.html

Some of the grammar productions referenced there are defined on earlier
pages.  As you can read there, the syntax Python allows for floats tries to
avoid confusion between prefixes of floats and octal integer literals.  So

    0e-6

is not allowed, and neither is

    01.1

nor

    00.0

Note that

    0.0
    0.
    .0
    0.e-6
    .0e-6
    0.0e-6

are allowed, though.

Continuing to ask "why?" beyond that is likely to be an unsatisfying hobby
<wink>.





More information about the Python-list mailing list