How convert string '1e7' to an integer?

Thomas thom1948 at gmail.com
Sun Nov 8 07:40:29 EST 2009


Just a curiosity, why does Python do this?

>>> l = [(base, int('1e7', base=base)) for base in range(15,37)]
>>> l
[(15, 442), (16, 487), (17, 534), (18, 583), (19, 634), (20, 687),
(21, 742), (22, 799), (23, 858), (24, 919), (25, 982), (26, 1047),
(27, 1114), (28, 1183), (29, 1254), (30, 1327), (31, 1402), (32,
1479), (33, 1558), (34, 1639), (35, 1722), (36, 1807)]
>>> l = ([base, int('1e7', base=base)] for base in range(15,37))
>>> l
<generator object at 0x027803A0>
>>>



More information about the Python-list mailing list