string methods (warning, newbie)
Nick Coghlan
ncoghlan at iinet.net.au
Sat Feb 26 23:14:55 EST 2005
Jimmy Retzlaff wrote:
> The approach you are considering may be easier than you think:
>
>
>>>>filter(str.isalpha, 'The Beatles - help - 03 - Ticket to ride')
>
> 'TheBeatleshelpTickettoride'
Hmm, I think this is a case where filter is significantly clearer than the
equivalent list comprehension:
Py> "".join([c for c in 'The Beatles - help - 03 - Ticket to ride' if c.isalpha(
)])
'TheBeatleshelpTickettoride'
Py>
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
More information about the Python-list
mailing list