[Tutor] Best way to convert list of ints to a string?
alan.gauld at btinternet.com
Sat Apr 26 09:37:47 CEST 2008
"Dick Moores" <rdm at rcblue.com> wrote
> And for intList = [0,1,2,3,4,5,6,7,8,9], this is 2X slower than
> ''.join(map(str, intList)) .
> But for intList = 1000*[0,1,2,3,4,5,6,7,8,9],
> ''.join(itertools.imap(str, intList)) has a very small edge.
> Thanks, Kent, both of those are in my "never knew" category.
You could have used the more familiar:
''.join(str(n) for n in intList)
Whis is just map using a comprehension style...
More information about the Tutor