string methods (warning, newbie)
anthonyberet
nospam at me.invalid
Sun Feb 27 07:40:17 EST 2005
Jimmy Retzlaff wrote:
> Anthonyberet wrote:
>
>>Is there a string mething to return only the alpha characters of a
>
> string?
>
>>eg 'The Beatles - help - 03 - Ticket to ride', would be
>>'TheBeatlesTickettoride'
>>
>>If not then how best to approach this?
>>I have some complicated plan to cut the string into individual
>>characters and then concatenate a new string with the ones that return
>>true with the .isalpha string method.
>>
>>Is there an easier way?
>
>
> The approach you are considering may be easier than you think:
>
>
>>>>filter(str.isalpha, 'The Beatles - help - 03 - Ticket to ride')
>
> 'TheBeatleshelpTickettoride'
>
Thanks very much - that's the level of knowledge of Python that I just
don't have yet - everything I try to do seems to have a much easier way,
that I haven't encountered yet :)
I shall read up on the elements of your code to understand exactly what
it is doing.
More information about the Python-list
mailing list