Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    floats = [float(v) for v in integerList]
or less idiomatic

    floats = map(float, integerList)


Except that these are different -- the second returns an iterator (at least in python3). You'd need

   list(map(float, integerList)) 
for them to be equivalent.

(It doesn't matter in a lot of cases, but there are enough edges where it does. Json serialization for one)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: