There's got to be an easy way to do this (fwd)
Remco Gerlich
scarblac at pino.selwerd.nl
Sun Jul 8 10:49:58 EDT 2001
Alex Martelli <aleaxit at yahoo.com> wrote in comp.lang.python:
> "Lulu of the Lotus-Eaters" <mertz at gnosis.cx> wrote in message
> news:mailman.994355168.2401.python-list at python.org...
> ...
> > filter(lambda c:c.isdigit(), '(123)/456-7890')
> >
> > Thirteen characters shorter than Emile's, and still no [re] :-).
> >
> > Personally, I even find it easier to read. YMMV.
>
> filter(string.isdigit, '(123)/456-7890')
>
> is six fewer characters and IMHO more readable still.
That version would certainly be best, if string had a isdigit function.
--
Remco Gerlich
More information about the Python-list
mailing list