Why is the minus sign below considered an invalid token? There must be something I do not understand here.
>>> [1e-i for i in range(-10,10)]
SyntaxError: invalid token
Normally these things evaluate like a mother:
>>> 1e-10
1e-10
I’m just curious; I solved my problem with
>>> [10**i for i in range(-10,10)]
[1e-10, 1e-09, 1e-08, 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]
1e-01etc are numeric literals. They’re seen and tokenized before the script ever runs. And the rules for such a number almost certainly say “an optional (‘E’ or ‘e’, followed by an optional ‘+’ or ‘-‘, followed by digits)”. There’s no provision for variables in that definition, and changing the definition would make it so numeric literals couldn’t be parsed til runtime, which would get very hairy.