Re: non printable (moving away from Perl)

2016-03-11 Thread Ben Finney
Fillmore writes: > On 3/11/2016 2:23 PM, MRAB wrote: > > Python 3 (Unicode) strings have an .isprintable method: > > > > mystring.isprintable() > > my strings are UTF-8. Will it work there too? You need to always be clear on the difference between text (the Python 3 ‘str’ type) versus bytes. It

Re: non printable (moving away from Perl)

2016-03-11 Thread Fillmore
On 3/11/2016 2:23 PM, MRAB wrote: On 2016-03-11 00: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;} :) Python 3 (Unicode) strings h

Re: non printable (moving away from Perl)

2016-03-11 Thread MRAB
On 2016-03-11 00: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;} :) Python 3 (Unicode) strings have an .isprintable method: mystri

Re: non printable (moving away from Perl)

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 9:34 AM, Wolfgang Maier wrote: > On 11.03.2016 15:23, Fillmore wrote: >> >> On 03/11/2016 07:13 AM, Wolfgang Maier wrote: >>> >>> One lesson for Perl regex users is that in Python many things can be >>> solved without regexes. >>> How about defining: >>> >>> printable = {ch

Re: non printable (moving away from Perl)

2016-03-11 Thread Wolfgang Maier
On 11.03.2016 15:23, Fillmore wrote: On 03/11/2016 07:13 AM, Wolfgang Maier wrote: 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)):

Re: non printable (moving away from Perl)

2016-03-11 Thread Peter Otten
Fillmore wrote: > On 03/11/2016 07:13 AM, Wolfgang Maier wrote: >> 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)): >>

Re: non printable (moving away from Perl)

2016-03-11 Thread Fillmore
On 03/11/2016 07:13 AM, Wolfgang Maier wrote: 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 seems computationally heav

Re: non printable (moving away from Perl)

2016-03-11 Thread Marko Rauhamaa
Wolfgang Maier : > On 11.03.2016 13:13, Wolfgang Maier wrote: >> 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)): >>

Re: non printable (moving away from Perl)

2016-03-11 Thread Wolfgang Maier
On 11.03.2016 13:13, Wolfgang Maier wrote: 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 Err, I meant: if (set(my_str

Re: non printable (moving away from Perl)

2016-03-11 Thread Wolfgang Maier
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 wh

Re: non printable (moving away from Perl)

2016-03-10 Thread Ian Kelly
On Mar 10, 2016 6:33 PM, "Mark Lawrence" wrote: > > On 11/03/2016 00:25, Ian Kelly wrote: >> >> On Mar 10, 2016 5:15 PM, "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 cont

Re: non printable (moving away from Perl)

2016-03-10 Thread Mark Lawrence
On 11/03/2016 00:25, Ian Kelly wrote: On Mar 10, 2016 5:15 PM, "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;} Python's re module

Re: non printable (moving away from Perl)

2016-03-10 Thread Ian Kelly
On Mar 10, 2016 5:15 PM, "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;} Python's re module doesn't support POSIX character c

non printable (moving away from Perl)

2016-03-10 Thread Fillmore
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;} :) -- https://mail.python.org/mailman/listinfo/python-list