>> 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,
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
Pyth
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)
[GCC
On 05/31/2012 03:10 PM, Chris Angelico wrote:
> On Fri, Jun 1, 2012 at 6:28 AM, 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 you
On Fri, Jun 1, 2012 at 6:28 AM, 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 regular expr
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
On 30 mai, 08:52, "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 string
On 30 mai, 13:54, 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\
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 rechec
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
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' pre
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\u30
On 30 May 2012 12:54, Thomas Rachel
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' r']'
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python
On Wed, May 30, 2012 at 2: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?)
>
> And is there no choice for me but to choose between the two
> poo
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
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 li
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 string of length 6 consisting of a backslash,
'u', '3' and th
> -Original Message-
> From:
> [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> rg] On Behalf Of Scott David Daniels
> Sent: 03 October 2006 18:11
> To: python-list@python.org
> Subject: Re: Raw strings and escaping
>
> Matthew Warren wrote:
> >
Matthew Warren wrote:
> Hi,
>
> I would expect this to work,
>
> rawstring=r'some things\new things\some other things\'
>
> But it fails as the last backslash escapes the single quote.
Note something many people don't when looking over the string rules:
astring = r'some things\new things\som
Jon Ribbens <[EMAIL PROTECTED]> wrote:
> Well, hardly *much* harder:
>
> pattern = r"""foo"""
It means you have to always triple quote your raw strings or know in
advance of writing the regular expression which of r'', r"", r'',
r"" is most appropriate. The way it works at the moment
In article <[EMAIL PROTECTED]>, Duncan Booth wrote:
>> I presume there was originally some reason for this bizarre behaviour
>> - it'd be interesting to know what it is/was, if anyone knows?
>>
> See the FAQ for the explanation:
>
> http://www.python.org/doc/faq/general/#why-can-t-raw-strings-r-s
Matthew Warren wrote:
> I would expect this to work,
>
> rawstring=r'some things\new things\some other things\'
>
> But it fails as the last backslash escapes the single quote.
raw string literals are parsed in exactly the same way as ordinary string
literals; it's
just the mapping from the stri
Jon Ribbens <[EMAIL PROTECTED]> wrote:
> I presume there was originally some reason for this bizarre behaviour
> - it'd be interesting to know what it is/was, if anyone knows?
>
See the FAQ for the explanation:
http://www.python.org/doc/faq/general/#why-can-t-raw-strings-r-strings-end-with-a-bac
In article <[EMAIL PROTECTED]>, Matthew Warren wrote:
> I would expect this to work,
>
> rawstring=r'some things\new things\some other things\'
>
> But it fails as the last backslash escapes the single quote.
String constants in Python are weird - raw strings doubly so.
In a raw string, backslas
"Matthew Warren" <[EMAIL PROTECTED]> wrote:
> I would expect this to work,
>
> rawstring=r'some things\new things\some other things\'
>
> But it fails as the last backslash escapes the single quote.
>
> ..although writing this I think I have solved my own problem. Is \'
> the only thing escaped
Matthew Warren wrote in news:mailman.1152.1159872720.10491.python-
[EMAIL PROTECTED] in comp.lang.python:
> I would expect this to work,
>
> rawstring=r'some things\new things\some other things\'
It in the docs:
http://docs.python.org/ref/strings.html#l2h-14>
... Specifically, a raw string ca
Hi,
I would expect this to work,
rawstring=r'some things\new things\some other things\'
But it fails as the last backslash escapes the single quote.
..although writing this I think I have solved my own problem. Is \' the
only thing escaped in a raw string so you can place ' in a raw string?
Alt
Alex Martelli wrote:
> John Salerno <[EMAIL PROTECTED]> wrote:
>
>> Alex Martelli wrote:
>>
Now get back to work on your new Nutshell book :-)
>>> Yep, good point!-)
>> Are you working on a new edition? I didn't see any new Python books
>> listed on O'Reilly's site through April, but I'd def
John Salerno <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
>
> >> Now get back to work on your new Nutshell book :-)
> >
> > Yep, good point!-)
>
> Are you working on a new edition? I didn't see any new Python books
> listed on O'Reilly's site through April, but I'd definitely be
> intere
Interesting, so thats where this comes from.
Of course the problem is that I thought that a raw string was a
different animal than a regular string (i.e. truely "raw" where no
characters are special, except of course the closing quote) so parsing
consistency is surprising to an end user (who has a
Alex Martelli wrote:
>> Now get back to work on your new Nutshell book :-)
>
> Yep, good point!-)
Are you working on a new edition? I didn't see any new Python books
listed on O'Reilly's site through April, but I'd definitely be
interested in new versions of the books I plan to get soon (Cookb
[EMAIL PROTECTED] wrote:
> I guess my point is that it is quite surprising that r'\' is not a
> legal way to represent a backslash. I look for consistency in the
> tools that I work with and this except-for-the-last-character exception
> is annoying
you seem to be missing that "exception" you th
Fredrik Lundh wrote:
> "Blackbird" <[EMAIL PROTECTED]> wrote:
>
>> Slightly OT, but here is a crazy little program that shows the power
>> of using raw strings:
>>
>> s=r'print "s=r\'%s\'\n%s"%(s,s)'
>> print "s=r\'%s\'\n%s"%(s,s)
>>
>> When run, this program will print an exact copy of itself.
>
>
"Blackbird" <[EMAIL PROTECTED]> wrote:
> Slightly OT, but here is a crazy little program that shows the power of
> using raw strings:
>
> s=r'print "s=r\'%s\'\n%s"%(s,s)'
> print "s=r\'%s\'\n%s"%(s,s)
>
> When run, this program will print an exact copy of itself.
I'm not sure what the raw strings
Almost off-topic.
Well, okay, completely off-topic.
On Sun, 05 Mar 2006 19:47:07 -0800, plahey wrote:
> I would say that a foolish anything is something to avoid. I don't
> think that anyone would claim that inconsistency is a virtue in a
> computer language (or in anything else for that matter
Slightly OT, but here is a crazy little program that shows the power of
using raw strings:
s=r'print "s=r\'%s\'\n%s"%(s,s)'
print "s=r\'%s\'\n%s"%(s,s)
When run, this program will print an exact copy of itself.
Blackbird
--
http://mail.python.org/mailman/listinfo/python-list
>Alas, somebody will now quote Emerson at you, I fear;-).
Let them come :-)
I almost always see this (mis)quoted as:
"consistency is the hobgoblin of little minds"
which is not really what Emerson said. The full quote is:
"A foolish consistency is the hobgoblin of little minds"
I would say t
[EMAIL PROTECTED] wrote:
> Hi,
>
> thanks for the reply. I was not aware of this in raw strings (and
> frankly, don't like it... but who cares about that :-) )
>
Healthy attitude!
> When I needed embedded quotes in a raw string I went the triple quote
> route:
<[EMAIL PROTECTED]> wrote:
> thanks for the reply. I can see that there is a choice that needed to
> be made. Before I was aware of the \ issue I just used (yes it has
> come up, but the example is at work) triple quotes to work around the
> embedded quote issue:
>
> x=r'''It's like this "c:\bl
Hi Steven,
thanks for the reply. I was/am aware that raw strings are mainly used
for regular expressions (and franky that was I usually use them for).
I was not aware that they still have "special powers" in raw strings
(thanks for the link!).
This one bit me when I was doing some quick and dirt
Hi Alex,
thanks for the reply. I can see that there is a choice that needed to
be made. Before I was aware of the \ issue I just used (yes it has
come up, but the example is at work) triple quotes to work around the
embedded quote issue:
x=r'''It's like this "c:\blah\" ok?'''
print x
It's like
Hi,
thanks for the reply. I was not aware of this in raw strings (and
frankly, don't like it... but who cares about that :-) )
When I needed embedded quotes in a raw string I went the triple quote
route:
a = r'''check \' this'''
which makes more
On Sun, 05 Mar 2006 08:27:31 -0800, plahey wrote:
> Hi Duncan,
>
> thanks for the reply. I figured that this was a technical problem
> associated with the parser.
>
> This one is going on my Python gotchas list. It is really silly from
> an end user perspective to have \ not special in raw str
[EMAIL PROTECTED] wrote:
> Hi Duncan,
>
> thanks for the reply. I figured that this was a technical problem
> associated with the parser.
>
> This one is going on my Python gotchas list. It is really silly from
> an end user perspective to have \ not special in raw strings _except_
> if it is the
<[EMAIL PROTECTED]> wrote:
> Hi Duncan,
>
> thanks for the reply. I figured that this was a technical problem
> associated with the parser.
>
> This one is going on my Python gotchas list. It is really silly from
> an end user perspective to have \ not special in raw strings _except_
> if it i
Hi Duncan,
thanks for the reply. I figured that this was a technical problem
associated with the parser.
This one is going on my Python gotchas list. It is really silly from
an end user perspective to have \ not special in raw strings _except_
if it is the last character.
--
http://mail.pytho
wrote:
> I thought I understood raw strings, then I got bitten by this:
>
> x=r'c:\blah\'
>
> which is illegal! I thought that \ had no special meanning in a raw
> string so why can't it be the last character?
No, the backslash is still special in terms of parsing the string, it
is simply th
I thought I understood raw strings, then I got bitten by this:
x=r'c:\blah\'
which is illegal! I thought that \ had no special meanning in a raw
string so why can't it be the last character?
making me do:
x=r'c:\blah' '\\'
is just silly...
--
http://mail.python.org/mailman/listinfo/python-l
48 matches
Mail list logo