Fastest way to detect a non-ASCII character in a list of strings.
Dun Peal
dunpealer at gmail.com
Tue Oct 19 20:07:59 EDT 2010
On Mon, Oct 18, 2010 at 1:41 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Or, a bit shorter, using Cython 0.13:
>
> def only_allowed_characters(list strings):
> cdef unicode s
> return any((c < 31 or c > 127)
> for s in strings for c in s)
Very cool, this caused me to look up the 0.13 release notes:
http://wiki.cython.org/ReleaseNotes-0.13
So they support generator expressions inside all() et al now... Makes
you wonder how long till they support them generally ;-)
D
More information about the Python-list
mailing list