How to convert unicode list to ascii list?

Gerhard Häring lists at ghaering.de
Thu Mar 20 11:32:25 EST 2003


Miki Tebeka wrote:
>>How can I convert this list to a normal ASCII list so that I can access each
>>element as ASCII?
> 
> ascii_groups = map(lambda s: s.encode('ascii'), groups

ascii_groups = [s.encode('ascii') for s in groups]

Clearer, shorter, and incompatible with Python 1.5.2. *All* of these are 
desirable features for me :-D

-- Gerhard






More information about the Python-list mailing list