Re: How convert string '1e7' to an integer?
by Mick Krippendorf other posts by this author
Nov 8 2009 5:47AM messages near this date
Re: How convert string '1e7' to an integer?
|
Re: How convert string '1e7' to an integer?
Thomas wrote:
> Just a curiosity, why does Python do this?
>
> >>> [(base, int('1e7', base=base)) for base in range(15,37)]
> [(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)]
> >>> ([base, int('1e7', base=base)] for base in range(15,37))
> <generator object at 0x027803A0>
Because the former is a list comprehension, whereas the latter is a
generator expression.
Mick.
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Peng Yu
Christian Heimes
Thomas
Mick Krippendorf
Roel Schroeven
Benjamin Kaplan
Mrab
Ben Finney
Mensanator
Gary Herron
Mick Krippendorf
Tim Chase
|