non printable (moving away from Perl)

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Fri Mar 11 07:13:00 EST 2016


One lesson for Perl regex users is that in Python many things can be 
solved without regexes. How about defining:

printable = {chr(n) for n in range(32, 127)}

then using:

if (set(my_string) - set(printable)):
     break



On 11.03.2016 01:07, Fillmore wrote:
>
> Here's another handy Perl regex which I am not sure how to translate to
> Python.
>
> I use it to avoid processing lines that contain funny chars...
>
> if ($string =~ /[^[:print:]]/) {next OUTER;}
>
> :)
>




More information about the Python-list mailing list