Re: r"\"" ??? (was A simple single line, triple-quoted comment)

2015-04-03 Thread Rustom Mody
On Friday, April 3, 2015 at 8:10:54 PM UTC+5:30, Chris Angelico wrote: > On Fri, Apr 3, 2015 at 11:52 PM, Rustom Mody wrote: > > Speaking about silliness of definitions, I was knocked out in class by this > > today: > > > r"\"" > > '\\"' > > > > Seeing the docs > > https://docs.python.org/3.

Re: r"\"" ??? (was A simple single line, triple-quoted comment)

2015-04-03 Thread Chris Angelico
On Fri, Apr 3, 2015 at 11:52 PM, Rustom Mody wrote: > Speaking about silliness of definitions, I was knocked out in class by this > today: > r"\"" > '\\"' > > Seeing the docs > https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals > it talks of this explicitly

Re: r"string" vs R"string

2010-01-18 Thread Terry Reedy
On 1/18/2010 8:01 AM, Colin W. wrote: On 17-Jan-10 18:27 PM, Steven D'Aprano wrote: On Sun, 17 Jan 2010 11:13:48 -0500, Roy Smith wrote: In article, "Colin W." wrote: On 17-Jan-10 02:16 AM, Terry Reedy wrote: On 1/17/2010 1:55 AM, Brendan Miller wrote: Is there any difference whatsoever be

Re: r"string" vs R"string

2010-01-18 Thread Colin W.
On 17-Jan-10 18:27 PM, Steven D'Aprano wrote: On Sun, 17 Jan 2010 11:13:48 -0500, Roy Smith wrote: In article, "Colin W." wrote: On 17-Jan-10 02:16 AM, Terry Reedy wrote: On 1/17/2010 1:55 AM, Brendan Miller wrote: Is there any difference whatsoever between a raw string beginning with th

Re: r"string" vs R"string

2010-01-17 Thread Steven D'Aprano
On Sun, 17 Jan 2010 11:13:48 -0500, Roy Smith wrote: > In article , > "Colin W." wrote: > >> On 17-Jan-10 02:16 AM, Terry Reedy wrote: >> > On 1/17/2010 1:55 AM, Brendan Miller wrote: >> >> Is there any difference whatsoever between a raw string beginning >> >> with the captical R or one with t

Re: r"string" vs R"string

2010-01-17 Thread Aahz
In article , Colin W. wrote: >On 17-Jan-10 02:16 AM, Terry Reedy wrote: >> On 1/17/2010 1:55 AM, Brendan Miller wrote: >>> >>> Is there any difference whatsoever between a raw string beginning with >>> the captical R or one with the lower case r e.g. r"string" vs >>> R"string"? >> >> No. Nor is th

Re: r"string" vs R"string

2010-01-17 Thread Roy Smith
In article , "Colin W." wrote: > On 17-Jan-10 02:16 AM, Terry Reedy wrote: > > On 1/17/2010 1:55 AM, Brendan Miller wrote: > >> Is there any difference whatsoever between a raw string beginning with > >> the captical R or one with the lower case r e.g. r"string" vs > >> R"string"? > > > > No. No

Re: r"string" vs R"string

2010-01-17 Thread Colin W.
On 17-Jan-10 02:16 AM, Terry Reedy wrote: On 1/17/2010 1:55 AM, Brendan Miller wrote: Is there any difference whatsoever between a raw string beginning with the captical R or one with the lower case r e.g. r"string" vs R"string"? No. Nor is there and difference between the strings created with

Re: r"string" vs R"string

2010-01-16 Thread Terry Reedy
On 1/17/2010 1:55 AM, Brendan Miller wrote: Is there any difference whatsoever between a raw string beginning with the captical R or one with the lower case r e.g. r"string" vs R"string"? No. Nor is there and difference between the strings created with raw literals and cooked literals. -- h

Re: r"string" vs R"string

2010-01-16 Thread Ben Finney
Brendan Miller writes: > Is there any difference whatsoever between a raw string beginning with > the captical R or one with the lower case r e.g. r"string" vs > R"string"? For answering questions like this, the Python language reference is your friend: String literals may optionally be pre

Re: r""

2008-09-30 Thread Lie Ryan
On Tue, 30 Sep 2008 10:50:01 -0700, Kyle Hayes wrote: >> Please describe the actual problem you're trying to solve. In what way >> do slashes need to be "fixed," and why? > > Well, I have decided to build a tool to help us sync files in UNC paths. > I am just building the modules and classes righ

Re: r""

2008-09-30 Thread Carsten Haese
Kyle Hayes wrote: >> Please describe the actual problem you're trying to solve. In what way >> do slashes need to be "fixed," and why? > > Well, I have decided to build a tool to help us sync files in UNC > paths. I am just building the modules and classes right now so I > haven't developed the fr

Re: r""

2008-09-30 Thread Mark Thomas
On Sep 30, 1:17 pm, Kyle Hayes <[EMAIL PROTECTED]> wrote: > Is there a way to use the 'r' in front of a variable instead of > directly in front of a string? Or do I need to use a function to get > all of the slashes automatically fixed? Is this what you're talking about? str = "foo/bar" re =

Re: r""

2008-09-30 Thread Kyle Hayes
> Please describe the actual problem you're trying to solve. In what way > do slashes need to be "fixed," and why? Well, I have decided to build a tool to help us sync files in UNC paths. I am just building the modules and classes right now so I haven't developed the frontend yet. I am assuming wh

Re: r""

2008-09-30 Thread Carsten Haese
Kyle Hayes wrote: > Is there a way to use the 'r' in front of a variable instead of > directly in front of a string? Or do I need to use a function to get > all of the slashes automatically fixed? Please describe the actual problem you're trying to solve. In what way do slashes need to be "fixed,"

Re: r' question

2008-05-18 Thread Gabriel Genellina
En Sun, 18 May 2008 02:49:03 -0300, Dick Moores <[EMAIL PROTECTED]> escribió: > However, (please refer back to my original post) > I want to keep the fstr, ultimately to be the > string entered by the user who knows a bit about > regex, but not how to use r' ' . Or > alternatively, not assume any

Re: r' question

2008-05-17 Thread Dick Moores
At 10:17 PM 5/17/2008, Gabriel Genellina wrote: En Sat, 17 May 2008 23:37:16 -0300, Dick Moores <[EMAIL PROTECTED]> escribió: > I have a text file of phone numbers, which I'd like to search with a regex. > > fstr = "\sjoe\s" > regex = "^.*" + fstr + ".*$" > > fstr = "\sjoe\s" > regex = "r'^.*" +

Re: r' question

2008-05-17 Thread Gabriel Genellina
En Sat, 17 May 2008 23:37:16 -0300, Dick Moores <[EMAIL PROTECTED]> escribió: > I have a text file of phone numbers, which I'd like to search with a regex. > > fstr = "\sjoe\s" > regex = "^.*" + fstr + ".*$" > > fstr = "\sjoe\s" > regex = "r'^.*" + fstr + ".*$'" The r"..." is a signal to the pars

Re: 'r' vs 'rb' in csv (was Re: Python SHA-1 as a method for unique file identification ? [help!])

2006-06-26 Thread Andrew McNamara
>> On a semi-related note, I have a database on Linux that imports from a >> Macintosh CSV file. The 'csv' module says to always open files in >> binary mode, but this didn't work in my case: I had to open it as 'rU' >> (text with universal newlines) or 'csv' misparsed it. I'd like the >> program

Re: 'r' vs 'rb' in csv (was Re: Python SHA-1 as a method for unique file identification ? [help!])

2006-06-26 Thread John Machin
On 27/06/2006 6:39 AM, Mike Orr wrote: > Tim Peters wrote: >> [EP <[EMAIL PROTECTED]>] >>> This inquiry may either turn out to be about the suitability of the >>> SHA-1 (160 bit digest) for file identification, the sha function in >>> Python ... or about some error in my script >> It's your script.

Re: R Paul Johnson is out of the office.

2006-04-21 Thread Terry Reedy
"RK" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > ok, who's been playing with mailman? I am sure the problem is a mis-configured auto-responder robot. Nothing like telling the world that you are not around to watch your home or office, Reminds me of when newspapers used to

Re: R Paul Johnson is out of the office.

2006-04-21 Thread Jorge Godoy
RK wrote: > ok, who's been playing with mailman? I thought you were going to say something like "I hope he turned off the lights before leaving the office"... :-) -- Jorge Godoy <[EMAIL PROTECTED]> "Quidquid latine dictum sit, altum sonatur." - Qualquer coisa dita em latim soa profundo.

Re: R Paul Johnson is out of the office.

2006-04-21 Thread RK
ok, who's been playing with mailman? -- http://mail.python.org/mailman/listinfo/python-list

Re: %r

2006-03-11 Thread Fredrik Lundh
Blackbird wrote: > By "cargo cult programming", do you mean actually *running* the code? no, I mean basing your mental model of something on distant observations of superficial (or accidental) artifacts (like the perceived similarity between the output from repr() and the raw string literal synta

Re: %r

2006-03-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Blackbird wrote: > By "cargo cult programming", do you mean actually *running* the code? http://www.catb.org/~esr/jargon/html/C/cargo-cult-programming.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: %r

2006-03-06 Thread Blackbird
Blackbird wrote: > Blackbird <[EMAIL PROTECTED]> skrev: > >>> >> Is the interpreter in fact using repr(), or parts of it, to generate >> output when you type an expression at the command prompt? The >> results sure look similar. > > Let me clarify this: The interpreter uses eval. No doubt about

Re: %r

2006-03-06 Thread Blackbird
Blackbird <[EMAIL PROTECTED]> skrev: >> > Is the interpreter in fact using repr(), or parts of it, to generate > output when you type an expression at the command prompt? The > results sure look similar. Let me clarify this: The interpreter uses eval. No doubt about that. But >>> eval('f') >

Re: %r

2006-03-06 Thread Blackbird
Peter Hansen wrote: > [...]> > On the other hand, if 'something' is actually some arbitrary object, > then it's definitely not always true, especially for anything not > built in to Python. > > -Peter Yes, I had strings in mind. And I guess it will work with the other primitive types, but anythin

Re: %r

2006-03-06 Thread Blackbird
Fredrik Lundh wrote: > "Blackbird" <[EMAIL PROTECTED]> wrote: > [...] >>> >> a = 'I don\'t think so' >> print '%r' % a >>> "I don't think so" >> a = r'I don\'t think so' >> print "'%s'" % a >>> 'I don\'t think so' >> >> Excellent counterexample. Can something like this happen

Re: %r

2006-03-06 Thread Peter Hansen
Blackbird wrote: > a = 'something' > b = ('%r'%a) > eval(b) == a > > that in general should return True. I hope. But I'm sure there are > counterexamples to that, too. Provided 'something' is a string, that should be true, as should the simpler statement a == eval(repr(a)) (since '%r' is jus

Re: %r

2006-03-06 Thread Blackbird
Peter Hansen wrote: > Blackbird wrote: >> I'm trying to get a complete grip on %r. Is it true that the two >> programs >> >> a = '*anything the parser accepts*' >> print '%r' % a >> >> vs. >> >> a = r'*anything the parser accepts*' >> print "'%s'" % a >> >> always produce the same output, where *a

Re: %r

2006-03-06 Thread Fredrik Lundh
"Blackbird" <[EMAIL PROTECTED]> wrote: > >> [...] > > > a = 'I don\'t think so' > print '%r' % a > > "I don't think so" > a = r'I don\'t think so' > print "'%s'" % a > > 'I don\'t think so' > > Excellent counterexample. Can something like this happen for other things > than qu

Re: %r

2006-03-06 Thread Blackbird
Duncan Booth wrote: > Blackbird wrote: > >> [...] > a = 'I don\'t think so' print '%r' % a > "I don't think so" a = r'I don\'t think so' print "'%s'" % a > 'I don\'t think so' Excellent counterexample. Can something like this happen for other things than quotes? -- http://m

Re: %r

2006-03-06 Thread Peter Hansen
Blackbird wrote: > I'm trying to get a complete grip on %r. Is it true that the two programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts* can

Re: %r

2006-03-06 Thread Fredrik Lundh
"Blackbird" wrote: > I'm trying to get a complete grip on %r. Is it true that the two programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts* can be

Re: %r

2006-03-06 Thread Duncan Booth
Blackbird wrote: > I'm trying to get a complete grip on %r. Is it true that the two > programs > > a = '*anything the parser accepts*' > print '%r' % a > > vs. > > a = r'*anything the parser accepts*' > print "'%s'" % a > > always produce the same output, where *anything the parser accepts*

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Fredrik Lundh
John Machin wrote: > Many people don't appear to want to know why; they only want a solution > to what they perceive to be their current problem. and many people can identify a short HOWTO when they see it, and look things up in the documentation when they want the full story. reposting the docu

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Peter Hansen
Steven D'Aprano wrote: > So going back to the original question... if I open in "r" mode a text > file which was created under Windows, I will get \r characters in the > text and have to deal with them regardless of what platform I am running > Python under. Correct? Almost, but the way you phrase

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread John Machin
Steven D'Aprano wrote: > On Mon, 13 Jun 2005 11:53:25 +0200, Fredrik Lundh wrote: > > >><[EMAIL PROTECTED]> wrote: >> >> >>>It means in windows we should use 'wb' to write and 'rb' to read ? >>>Am I right? >> >>no. >> >>you should use "wb" to write *binary* files, and "rb" to read *binary* >>file

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Steven D'Aprano
On Mon, 13 Jun 2005 10:52:52 -0400, Peter Hansen wrote: > Steven D'Aprano wrote: >> When you read a Windows text file using "r" mode, what happens to the \r >> immediately before the newline? Do you have to handle it yourself? Or will >> Python cleverly suppress it so you don't have to worry about

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Terry Hancock
On Monday 13 June 2005 09:34 am, Steven D'Aprano wrote: > On Mon, 13 Jun 2005 11:53:25 +0200, Fredrik Lundh wrote: > > <[EMAIL PROTECTED]> wrote: > >> It means in windows we should use 'wb' to write and 'rb' to read ? > >> Am I right? > > no. > > you should use "wb" to write *binary* files, and "rb

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Peter Hansen
Steven D'Aprano wrote: > When you read a Windows text file using "r" mode, what happens to the \r > immediately before the newline? Do you have to handle it yourself? Or will > Python cleverly suppress it so you don't have to worry about it? > > And when you write a text file under Python using "w

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Steven D'Aprano
On Mon, 13 Jun 2005 11:53:25 +0200, Fredrik Lundh wrote: > <[EMAIL PROTECTED]> wrote: > >> It means in windows we should use 'wb' to write and 'rb' to read ? >> Am I right? > > no. > > you should use "wb" to write *binary* files, and "rb" to read *binary* > files. > > if you're working with *t

Re: \r\n or \n notepad editor end line ???

2005-06-13 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > It means in windows we should use 'wb' to write and 'rb' to read ? > Am I right? no. you should use "wb" to write *binary* files, and "rb" to read *binary* files. if you're working with *text* files (that is, files that contain lines of text separated by line separa

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread Greg Ewing
Peter Hansen wrote: > (I don't believe there's a "wU" and conceptually it's sort > of meaningless anyway, If we ever get quantum computers, presumably "wU" will write the newlines in all possible formats simultaneously... -- Greg Ewing, Computer Science Dept, University of Canterbury, C

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread [EMAIL PROTECTED]
Hello All, Thanks for the response. I use mysql and find something strange lately while load text file to my database table using LINES TERMINATED BY '\r\n', And I found that mysql think I have '\r\r\n'. this is happened because in one of my code I use 'w' to write element of string + '\r\n'. no

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > It means in windows we should use 'wb' to write and 'rb' to read ? > Am I right? There is a conceptual difference between "text" files and other files (which are lumped under the label "binary"). Binary files have any kind of data in them (bytes from 0 to 255) and no

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread Simon Brunning
On 8 Jun 2005 06:44:40 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > It means in windows we should use 'wb' to write and 'rb' to read ? > Am I right? It depends what you are trying to do with the file. If you are processing it as a text file, open it as a text file, and all will be well:

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread [EMAIL PROTECTED]
Hello thanks everyone, It means in windows we should use 'wb' to write and 'rb' to read ? Am I right? pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread Bill Mill
On 8 Jun 2005 06:24:05 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello, > > I use windows notepad editor to write text. > > For example I write (in d:\myfile.txt): > Helo > World > > If I open it with python: > FName = open(d:\myfile.txt,'r') > h = FName.readlines() > print h >

Re: \r\n or \n notepad editor end line ???

2005-06-08 Thread Max M
[EMAIL PROTECTED] wrote: > Hello, > > I use windows notepad editor to write text. > > For example I write (in d:\myfile.txt): > Helo > World > > If I open it with python: > FName = open(d:\myfile.txt,'r') > h = FName.readlines() > print h > > I get h : ['Helo\n', 'World'] > > I thought n

Re: \r functionality

2005-05-17 Thread Fredrik Lundh
"Jake" <[EMAIL PROTECTED]> wrote: > in c and c++ there is a useful way to refresh an output line in printf > and cout using \r meta command. that's a control character that's printed to the terminal by printf/cout, not a "C or C++ meta command" to print the same character in Python, use the same

Re: \r functionality

2005-05-17 Thread Duncan Booth
Jake wrote: > in c and c++ there is a useful way to refresh an output line in printf > and cout using \r meta command. So for example in the wget application > the progress of the download is updated on the same output line of the > screen. From an intital investigation python seems to lack this.

Re: \r functionality

2005-05-17 Thread Daniel Schüle
Jake wrote: > in c and c++ there is a useful way to refresh an output line in printf > and cout using \r meta command. So for example in the wget application > the progress of the download is updated on the same output line of the > screen. From an intital investigation python seems to lack this. I

Re: \r functionality

2005-05-17 Thread Markus Weihs
Hi! > in c and c++ there is a useful way to refresh an output line in printf > and cout using \r meta command. So for example in the wget application > the progress of the download is updated on the same output line of the > screen. From an intital investigation python seems to lack this. Is > thi