Fastest way to detect a non-ASCII character in a list of strings.

Dun Peal dunpealer at
Wed Oct 20 02:07:59 CEST 2010

On Mon, Oct 18, 2010 at 1:41 AM, Stefan Behnel <stefan_ml at> 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:

So they support generator expressions inside all() et al now... Makes
you wonder how long till they support them generally ;-)


More information about the Python-list mailing list