string methods (warning, newbie)
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Mon Feb 28 16:43:46 EST 2005
More information about the Python-list mailing list
Mon Feb 28 16:43:46 EST 2005
- Previous message (by thread): string methods (warning, newbie)
- Next message (by thread): string methods (warning, newbie)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 27 Feb 2005 18:12:17 -0700, rumours say that Steven Bethard <steven.bethard at gmail.com> might have written: [snip Nick Coghlan's list comprehension] [STeVe] >On the other hand, filter doesn't do the same thing: > >py> s = u'The Beatles - help - 03 - Ticket to ride' >py> filter(str.isalpha, s) >Traceback (most recent call last): > File "<interactive input>", line 1, in ? >TypeError: descriptor 'isalpha' requires a 'str' object but received a >'unicode' >py> ''.join(c for c in s if c.isalpha()) >u'TheBeatleshelpTickettoride' This works though: .>> filter(type(s).isalpha, s) As a function just for clarity. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually...
- Previous message (by thread): string methods (warning, newbie)
- Next message (by thread): string methods (warning, newbie)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list