[BangPypers] Another qn. THanks for the basic of basic qn\

Gora Mohanty gora at mimirtech.com
Wed May 8 20:07:11 CEST 2013


On 8 May 2013 23:00, Jagadeesh N. Malakannavar <mnjagadeesh at gmail.com> wrote:
> I prefer to do it like this
>
>>>> a = list(str(3245325))
>>>> sum(map(int, a))
> 24

What does the map() gain you over basic list comprehension:
   sum( [int(i) for i in '3245325'] )
ignoring any try/catch for int conversion errors

IMHO, this is easier to understand, more Pythonic, and likely
faster.

Regards,
Gora


More information about the BangPypers mailing list