Re: python3 raw strings and \u escapes

2012-06-15 Thread Jason Friedman
This is a related question. I perform an octal dump on a file: $ od -cx file 000 h e l l o w o r l d \n 65686c6c206f6f776c720a64 I want to output the names of those characters: $ python3 Python 3.2.3 (default, May 19 2012, 17:01:30)

Re: python3 raw strings and \u escapes

2012-06-15 Thread MRAB
On 16/06/2012 00:42, Jason Friedman wrote: This is a related question. I perform an octal dump on a file: $ od -cx file 000 h e l l o w o r l d \n 65686c6c206f6f776c720a64 I want to output the names of those characters: $ python3

Re: python3 raw strings and \u escapes

2012-06-15 Thread Jason Friedman
This is a related question. I perform an octal dump on a file: $ od -cx file 000   h   e   l   l   o       w   o   r   l   d  \n            6568    6c6c    206f    6f77    6c72    0a64 I want to output the names of those characters: $ python3 Python 3.2.3 (default, May 19 2012,

Re: python3 raw strings and \u escapes

2012-05-31 Thread ru...@yahoo.com
On 05/30/2012 09:07 AM, ru...@yahoo.com wrote: On 05/30/2012 05:54 AM, Thomas Rachel wrote: Am 30.05.2012 08:52 schrieb ru...@yahoo.com: This breaks a lot of my code because in python 2 re.split (ur'[\u3000]', u'A\u3000A') == [u'A', u'A'] but in python 3 (the result of running 2to3),

Re: python3 raw strings and \u escapes

2012-05-31 Thread Chris Angelico
On Fri, Jun 1, 2012 at 6:28 AM, ru...@yahoo.com ru...@yahoo.com wrote: ... a lexer module that is structured as many dozens of little functions, each with a docstring that is a regex string. This may be a good opportunity to take a step back and ask yourself: Why so many functions, each with a

Re: python3 raw strings and \u escapes

2012-05-31 Thread ru...@yahoo.com
On 05/31/2012 03:10 PM, Chris Angelico wrote: On Fri, Jun 1, 2012 at 6:28 AM, ru...@yahoo.com ru...@yahoo.com wrote: ... a lexer module that is structured as many dozens of little functions, each with a docstring that is a regex string. This may be a good opportunity to take a step back and

Re: python3 raw strings and \u escapes

2012-05-30 Thread Andrew Berg
On 5/30/2012 1:52 AM, ru...@yahoo.com wrote: Was there a reason for dropping the lexical processing of \u escapes in strings in python3 (other than to add another annoyance in a long list of python3 annoyances?) To me, this would be a Python 2 annoyance since I would expect r'\u3000' to be

Re: python3 raw strings and \u escapes

2012-05-30 Thread Thomas Rachel
Am 30.05.2012 08:52 schrieb ru...@yahoo.com: This breaks a lot of my code because in python 2 re.split (ur'[\u3000]', u'A\u3000A') == [u'A', u'A'] but in python 3 (the result of running 2to3), re.split (r'[\u3000]', 'A\u3000A' ) == ['A\u3000A'] I can remove the r prefix from

Re: python3 raw strings and \u escapes

2012-05-30 Thread Devin Jeanpierre
On Wed, May 30, 2012 at 2:52 AM, ru...@yahoo.com ru...@yahoo.com wrote: Was there a reason for dropping the lexical processing of \u escapes in strings in python3 (other than to add another annoyance in a long list of python3 annoyances?) And is there no choice for me but to choose between

Re: python3 raw strings and \u escapes

2012-05-30 Thread Arnaud Delobelle
On 30 May 2012 12:54, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: There is a 3rd one: use   r'[ ' + '\u3000' + ']'. Not very nice to read, but should do the trick... You could even take advantage of string literal concatenation:) r'[' '\u3000'

Re: python3 raw strings and \u escapes

2012-05-30 Thread ru...@yahoo.com
On 05/30/2012 05:54 AM, Thomas Rachel wrote: Am 30.05.2012 08:52 schrieb ru...@yahoo.com: This breaks a lot of my code because in python 2 re.split (ur'[\u3000]', u'A\u3000A') == [u'A', u'A'] but in python 3 (the result of running 2to3), re.split (r'[\u3000]', 'A\u3000A' ) ==

Re: python3 raw strings and \u escapes

2012-05-30 Thread Terry Reedy
On 5/30/2012 2:52 AM, ru...@yahoo.com wrote: In python2, \u escapes are processed in raw unicode strings. That is, ur'\u3000' is a string of length 1 consisting of the IDEOGRAPHIC SPACE unicode character. That surprised me until I rechecked the fine manual and found: When an 'r' or 'R'

Re: python3 raw strings and \u escapes

2012-05-30 Thread Serhiy Storchaka
On 30.05.12 14:54, Thomas Rachel wrote: There is a 3rd one: use r'[ ' + '\u3000' + ']'. Not very nice to read, but should do the trick... Or r'[ %s]' % ('\u3000',). -- http://mail.python.org/mailman/listinfo/python-list

Re: python3 raw strings and \u escapes

2012-05-30 Thread ru...@yahoo.com
On 05/30/2012 10:46 AM, Terry Reedy wrote: On 5/30/2012 2:52 AM, ru...@yahoo.com wrote: In python2, \u escapes are processed in raw unicode strings. That is, ur'\u3000' is a string of length 1 consisting of the IDEOGRAPHIC SPACE unicode character. That surprised me until I rechecked the

Re: python3 raw strings and \u escapes

2012-05-30 Thread jmfauth
On 30 mai, 13:54, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5- a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 30.05.2012 08:52 schrieb ru...@yahoo.com: This breaks a lot of my code because in python 2        re.split (ur'[\u3000]', u'A\u3000A') ==  [u'A', u'A'] but in python 3 (the

Re: python3 raw strings and \u escapes

2012-05-30 Thread jmfauth
On 30 mai, 08:52, ru...@yahoo.com ru...@yahoo.com wrote: In python2, \u escapes are processed in raw unicode strings.  That is, ur'\u3000' is a string of length 1 consisting of the IDEOGRAPHIC SPACE unicode character. In python3, \u escapes are not processed in raw strings. r'\u3000' is a