How do I convert an iterator over bytes into a str?
breamoreboy at yahoo.co.uk
Wed Aug 19 00:54:13 CEST 2009
> This does what I expected:
> In : list(iter([1,2,3,4,5]))
> Out: [1, 2, 3, 4, 5]
> But this appears to be doing a __repr__ rather than making me a nice
> In : str(iter("four score and seven years ago"))
> Out: '<iterator object at 0x0139F190>'
> What's the correct way to turn an iterator over bytes into a string?
> This works, but, ewww:
> In : "".join(iter("four score and seven years ago"))
> Out: 'four score and seven years ago'
You've started with a string.
>>> type("four score and seven years ago")
More information about the Python-list