Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Nobody
On Sun, 16 Aug 2009 05:05:01 +, Steven D'Aprano wrote: > Now that I understand what the semantics of cout << "Hello world" are, I > don't have any problem with it either. It is a bit weird, "Hello world" > >> cout would probably be better, Placing the stream on the LHS allows the main forms

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 6:18 am, Steven D'Aprano wrote: > On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: > > I would definitely not like a language that obscures assignment by > > moving it over to the right side of lines. > One could argue that left-assigned-from-right assignment obscures the > mo

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 8:45 am, MRAB wrote: > No, APL is strictly right-to-left. > >      -> x > > means "goto x". > > Writing to the console is: > >      [] <- myVar > > Reading from the console is: > >      myVar <- [] Ah, thanks for the correction. It's been 5,000 years since I used APL! |>ouglas -- ht

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread MRAB
Douglas Alan wrote: [snip] C++ also allows for reading from stdin like so: cin >> myVar; I think the direction of the arrows probably derives from languages like APL, which had notation something like so: myVar <- 3 [] <- myVar "<-" was really a little arrow symbol (APL didn't us

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Hendrik van Rooyen
On Sunday 16 August 2009 12:18:11 Steven D'Aprano wrote: > In any case, after half a century of left-from-right assignment, I think > it's worth the experiment in a teaching language or three to try it the > other way. The closest to this I know of is the family of languages > derived from Apple's

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: > I like to be able to read everything from left to right, and Lisp does > that more than any other programming language. > > I would definitely not like a language that obscures assignment by > moving it over to the right side of lines. On

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 4:48 am, Erik Max Francis wrote: > Douglas Alan wrote: > > Personally, my favorite is Lisp, which looks like > > >    (set! y (+ y 1)) > > For varying values of "Lisp."  `set!` is Scheme. Yes, I'm well aware! There are probably as many different dialects of Lisp as all other programmi

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Erik Max Francis
Douglas Alan wrote: Personally, my favorite is Lisp, which looks like (set! y (+ y 1)) For varying values of "Lisp." `set!` is Scheme. -- Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis Get there

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Erik Max Francis
Steven D'Aprano wrote: I don't like normal assignment. After nearly four decades of mathematics and programming, I'm used to it, but I don't think it is especially good. It confuses beginners to programming: they get one set of behaviour drilled into them in maths class, and then in programming

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 4:22 am, Steven D'Aprano wrote: > I don't like normal assignment. After nearly four decades of mathematics > and programming, I'm used to it, but I don't think it is especially good. > It confuses beginners to programming: they get one set of behaviour > drilled into them in maths clas

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 09:24:36 +0200, Hendrik van Rooyen wrote: >>"Steven D'Aprano" wrote: > >>Now that I understand what the semantics of cout << "Hello world" are, I >>don't have any problem with it either. It is a bit weird, "Hello world" cout would probably be better, but it's hardly the

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Hendrik van Rooyen
>"Steven D'Aprano" wrote: >Now that I understand what the semantics of cout << "Hello world" are, I >don't have any problem with it either. It is a bit weird, "Hello world" >>> cout would probably be better, but it's hardly the strangest design in >any programming language, and it's probably

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 16, 1:05 am, Steven D'Aprano wrote: > On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: > > So, as far as I can tell, Python has no real authority to throw stones > > at C++ on this little tiny particular issue. > I think you're being a tad over-defensive. Defensive? Personally, I p

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Steven D'Aprano
On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: > So, as far as I can tell, Python has no real authority to throw stones > at C++ on this little tiny particular issue. I think you're being a tad over-defensive. I asked a genuine question about a quote in somebody's signature. That's a qu

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 15, 10:19 pm, Steven D'Aprano wrote: > On Sat, 15 Aug 2009 13:01:43 -0700, Douglas Alan wrote: > > P.S. I find it strange, however, that anyone who is not okay with > > "abusing" operator overloading in this manner, wouldn't also take > > umbrage at Python's overloading of "+" to work with

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Steven D'Aprano
On Sat, 15 Aug 2009 13:01:43 -0700, Douglas Alan wrote: > P.S. I find it strange, however, that anyone who is not okay with > "abusing" operator overloading in this manner, wouldn't also take > umbrage at Python's overloading of "+" to work with strings and lists, > etc. Numerical addition and seq

Re: Unrecognized escape sequences in string literals

2009-08-15 Thread Douglas Alan
On Aug 14, 1:55 pm, Steven D'Aprano wrote: > Douglas, you and I clearly have a difference of opinion on > this. Neither of us have provided even the tiniest amount > of objective, replicable, reliable data on the > error-proneness of the C++ approach versus that of > Python. The supposed superior

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread John Haggerty
I guess the problem is---does it actually matter? On Fri, Aug 14, 2009 at 10:11 AM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > > > "I saw `cout' being shifted "Hello world" times to the left and stopped > > right there." --S

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 14, 10:25 pm, Dave Angel wrote: > Benjamin Kaplan wrote: > > On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan wrote: > >> P.S. Overloading "left shift" to mean "output" does indeed seem a bit > >> sketchy, but in 15 years of C++ programming, I've never seen it cause > >> any confusion or b

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Chris Rebert
On Sat, Aug 15, 2009 at 4:47 AM, Hendrik van Rooyen wrote: > On Friday 14 August 2009 18:11:52 Steven D'Aprano wrote: >> On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: >> > "I saw `cout' being shifted "Hello world" times to the left and stopped >> > right there."  --Steve Gonedes >> >> Assuming th

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Hendrik van Rooyen
On Friday 14 August 2009 18:11:52 Steven D'Aprano wrote: > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > > "I saw `cout' being shifted "Hello world" times to the left and stopped > > right there." --Steve Gonedes > > Assuming that's something real, and not invented for humour, I presume > that

Re: Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Dave Angel
Benjamin Kaplan wrote: On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan wrote: P.S. Overloading "left shift" to mean "output" does indeed seem a bit sketchy, but in 15 years of C++ programming, I've never seen it cause any confusion or bugs. The only reason it hasn't is because people

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Benjamin Kaplan
On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan wrote: > > P.S. Overloading "left shift" to mean "output" does indeed seem a bit > sketchy, but in 15 years of C++ programming, I've never seen it cause > any confusion or bugs. The only reason it hasn't is because people use it in "Hello World". I

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Erik Max Francis
Grant Edwards wrote: On 2009-08-14, Erik Max Francis wrote: Grant Edwards wrote: On 2009-08-14, Steven D'Aprano wrote: What the hell would it actually do??? IIRC in C++, cout << "Hello world"; is equivalent to this in C: printf("Hellow world"); or this in Python: print "hello

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Grant Edwards
On 2009-08-14, Erik Max Francis wrote: > Grant Edwards wrote: >> On 2009-08-14, Steven D'Aprano wrote: >>> What the hell >>> would it actually do??? >> >> IIRC in C++, >> >>cout << "Hello world"; >> >> is equivalent to this in C: >> >>printf("Hellow world"); >> >> or this in Python:

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Erik Max Francis
Grant Edwards wrote: On 2009-08-14, Steven D'Aprano wrote: What the hell would it actually do??? IIRC in C++, cout << "Hello world"; is equivalent to this in C: printf("Hellow world"); or this in Python: print "hellow world" Well, plus or minus newlines. -- Erik Max Francis

Re: Unrecognized escape sequences in string literals

2009-08-14 Thread Steven D'Aprano
I think I've spent enough time on this discussion, so I won't be directly responding to any of your recent points -- it's clear that I'm not persuading you that there's any justification for any behaviour for escape sequences other than the way C++ deals with them. That's your prerogative, of c

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Douglas Alan
On Aug 14, 12:17 pm, Grant Edwards wrote: > On 2009-08-14, Steven D'Aprano wrote: > > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > >> "I saw `cout' being shifted "Hello world" times to the left and stopped > >> right there."  --Steve Gonedes > > > Assuming that's something real, and not i

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread MRAB
Grant Edwards wrote: On 2009-08-14, Steven D'Aprano wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: "I saw `cout' being shifted "Hello world" times to the left and stopped right there." --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's desc

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Grant Edwards
On 2009-08-14, Steven D'Aprano wrote: > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > >> "I saw `cout' being shifted "Hello world" times to the left and stopped >> right there." --Steve Gonedes > > Assuming that's something real, and not invented for humour, I presume > that's describing som

OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Steven D'Aprano
On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > "I saw `cout' being shifted "Hello world" times to the left and stopped > right there." --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? What the he

Re: Unrecognized escape sequences in string literals

2009-08-14 Thread Aahz
In article <6e13754c-1fa6-4d1b-8861-146bffec8...@h30g2000vbr.googlegroups.com>, Douglas Alan wrote: > >My friend begs to differ with the above. It would be much better for >debugging if Python generated a parsing error for unrecognized escape >sequences, rather than leaving them unchanged. g++ ou

Re: Unrecognized escape sequences in string literals

2009-08-13 Thread Douglas Alan
On Aug 12, 7:19 pm, Steven D'Aprano wrote: > You are making an unjustified assumption: \y is not an error. You are making in an unjustified assumption that I ever made such an assumption! My claim is and has always been NOT that \y is inately an error, but rather that treating unrecognized esca

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread MRAB
Steven D'Aprano wrote: On Wed, 12 Aug 2009 14:21:34 -0700, Douglas Alan wrote: On Aug 12, 5:32 am, Steven D'Aprano wrote: That problem basically boils down to a deep-seated philosophical disagreement over which philosophy a language should follow in regard to backslash escapes: "Anything no

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Steven D'Aprano
On Wed, 12 Aug 2009 14:21:34 -0700, Douglas Alan wrote: > On Aug 12, 5:32 am, Steven D'Aprano > wrote: > >> That problem basically boils down to a deep-seated philosophical >> disagreement over which philosophy a language should follow in regard >> to backslash escapes: >> >> "Anything not expli

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Douglas Alan
On Aug 12, 5:32 am, Steven D'Aprano wrote: > That problem basically boils down to a deep-seated > philosophical disagreement over which philosophy a > language should follow in regard to backslash escapes: > > "Anything not explicitly permitted is forbidden" > > versus > > "Anything not explicitl

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Douglas Alan
On Aug 12, 3:36 am, Steven D'Aprano wrote: > On Tue, 11 Aug 2009 13:20:52 -0700, Douglas Alan wrote: > > My "Annotated C++ Reference Manual" is packed, and surprisingly in > > Stroustrup's Third Edition, there is no mention of the issue in the > > entire 1,000 pages. But Microsoft to the rescue:

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Douglas Alan
On Aug 12, 3:08 am, Steven D'Aprano wrote: > On Tue, 11 Aug 2009 14:48:24 -0700, Douglas Alan wrote: > > In any case, my argument has consistently been that Python should have > > treated undefined escape sequences consistently as fatal errors, > > A reasonable position to take. I disagree with i

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Steven D'Aprano
On Tue, 11 Aug 2009 14:29:43 -0700, Douglas Alan wrote: > I need to preface this entire post with the fact that I've already used > ALL of the arguments that you've provided on my friend before I ever > even came here with the topic, and my own arguments on why Python can be > considered to be doi

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Steven D'Aprano
On Tue, 11 Aug 2009 13:20:52 -0700, Douglas Alan wrote: > On Aug 11, 2:00 pm, Steven D'Aprano cybersource.com.au> wrote: > >> > test.cpp:1:1: warning: unknown escape sequence '\y' >> >> Isn't that a warning, not a fatal error? So what does temp contain? > > My "Annotated C++ Reference Manual" i

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Steven D'Aprano
On Tue, 11 Aug 2009 14:48:24 -0700, Douglas Alan wrote: > In any case, my argument has consistently been that Python should have > treated undefined escape sequences consistently as fatal errors, A reasonable position to take. I disagree with it, but it is certainly reasonable. > not as warni

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
I wrote: > But you're right, it's too late to change this now. P.S. But if it weren't too late, I think that your idea to have "\s" be the escape sequence for a backslash instead of "\\" might be a good one. |>ouglas -- http://mail.python.org/mailman/listinfo/python-list

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 11, 4:38 pm, Ethan Furman wrote: > Mind you, I'm not really vested in how Python *should* handle > backslashes one way or the other, but I am glad it has rules that it > follows for consitent results, and I don't have to break out a byte-code > editor to find out what's in my string litera

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 10, 11:27 pm, Steven D'Aprano wrote: > On Mon, 10 Aug 2009 08:21:03 -0700, Douglas Alan wrote: > > But you're right, it's too late to change this now. > > Not really. There is a procedure for making non-backwards compatible > changes. If you care deeply enough about this, you could agitate

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
Steven D'Aprano wrote: > Because the cost isn't zero. Needing to write \\ in a string > literal when you want \ is a cost, I need to preface this entire post with the fact that I've already used ALL of the arguments that you've provided on my friend before I ever even came here with the topic, an

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Ethan Furman
Douglas Alan wrote: On Aug 11, 2:00 pm, Steven D'Aprano wrote: test.cpp:1:1: warning: unknown escape sequence '\y' Isn't that a warning, not a fatal error? So what does temp contain? My "Annotated C++ Reference Manual" is packed, and surprisingly in Stroustrup's Third Edition, there is n

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 11, 2:00 pm, Steven D'Aprano wrote: > > test.cpp:1:1: warning: unknown escape sequence '\y' > > Isn't that a warning, not a fatal error? So what does temp contain? My "Annotated C++ Reference Manual" is packed, and surprisingly in Stroustrup's Third Edition, there is no mention of the iss

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Steven D'Aprano
On Tue, 11 Aug 2009 15:50:01 +0200, Piet van Oostrum wrote: >> Steven D'Aprano (SD) wrote: > >>SD> If I'm reading this page correctly, Python does behave as C++ does. >>Or at SD> least as Larch/C++ does: > >>SD> http://www.cs.ucf.edu/~leavens/larchc++manual/lcpp_47.html > > They call them

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Ethan Furman
Steven D'Aprano wrote: On Mon, 10 Aug 2009 08:21:03 -0700, Douglas Alan wrote: But you're right, it's too late to change this now. Not really. There is a procedure for making non-backwards compatible changes. If you care deeply enough about this, you could agitate for Python 3.2 to raise

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Piet van Oostrum
> Steven D'Aprano (SD) wrote: >SD> If I'm reading this page correctly, Python does behave as C++ does. Or at >SD> least as Larch/C++ does: >SD> http://www.cs.ucf.edu/~leavens/larchc++manual/lcpp_47.html They call them `non-standard escape sequences' for a reason: that they are not in stand

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Steven D'Aprano
On Mon, 10 Aug 2009 15:17:24 -0700, Douglas Alan wrote: > From: Steven D'Aprano wrote: > >> On Mon, 10 Aug 2009 00:32:30 -0700, Douglas Alan wrote: > >> > In C++, if I know that the code I'm looking at compiles, then I never >> > need worry that I've misinterpreted what a string literal means.

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Steven D'Aprano
On Mon, 10 Aug 2009 08:21:03 -0700, Douglas Alan wrote: > But you're right, it's too late to change this now. Not really. There is a procedure for making non-backwards compatible changes. If you care deeply enough about this, you could agitate for Python 3.2 to raise a PendingDepreciation warni

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
From: Steven D'Aprano wrote: > On Mon, 10 Aug 2009 00:32:30 -0700, Douglas Alan wrote: > > In C++, if I know that the code I'm looking at compiles, > > then I never need worry that I've misinterpreted what a > > string literal means. > If you don't know what your string literals are, you don't

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Carl Banks
On Aug 10, 1:37 am, Steven D'Aprano wrote: > On Mon, 10 Aug 2009 00:37:33 -0700, Carl Banks wrote: > > On Aug 9, 11:10 pm, Steven D'Aprano > > wrote: > >> On Sun, 09 Aug 2009 18:34:14 -0700, Carl Banks wrote: > >> >> Why should a backslash in a string literal be an error? > > >> > Because the beh

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Carl Banks
On Aug 10, 4:41 am, MRAB wrote: > Steven D'Aprano wrote: > > On Sun, 09 Aug 2009 17:56:55 -0700, Douglas Alan wrote: > > [snip] > >> My point of view is that > >> every language has *some* warts; Python just has a bit fewer than most. > >> It would have been nice, I should think, if this wart had

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 10:58 am, Scott David Daniels wrote: > The string rules reflect C's rules, and I see little > excuse for trying to change them now. No they don't. Or at least not C++'s rules. C++ behaves exactly as I should like. (Or at least g++ does. Or rather *almost* as I would like, as by defau

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Scott David Daniels
Douglas Alan wrote: So, what's the one obvious right way to express "foo\zbar"? Is it "foo\zbar" or "foo\\zbar" And if it's the latter, what possible benefit is there in allowing the former? And if it's the former, why does Python echo the latter? Actually, if we were designing from fres

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 4:37 am, Steven D'Aprano > There is at least one good reason for preferring an error, namely that it > allows Python to introduce new escape codes without going through a long, > slow process. But the rest of these complaints are terribly unconvincing. What about: o Beautiful is b

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread MRAB
Steven D'Aprano wrote: On Sun, 09 Aug 2009 17:56:55 -0700, Douglas Alan wrote: [snip] My point of view is that every language has *some* warts; Python just has a bit fewer than most. It would have been nice, I should think, if this wart had been "fixed" in Python 3, as I do consider it to be a

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Duncan Booth
Steven D'Aprano wrote: > Or perhaps they should follow bash's lead, and map \C to C for every > character. If there were no special escapes at all, Windows > programmers wouldn't keep getting burnt when they write > "C:\\Documents\today\foo" and end up with something completely > unexpected. >

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Steven D'Aprano
On Mon, 10 Aug 2009 00:32:30 -0700, Douglas Alan wrote: > In C++, if I know that the code I'm looking at compiles, then I never > need worry that I've misinterpreted what a string literal means. If you don't know what your string literals are, you don't know what your program does. You can't exp

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Duncan Booth
Douglas Alan wrote: > "\xba" isn't an escape sequence in any other language that I've used, > which is one reason I made this error... Oh, wait a minute -- it *is* > an escape sequence in JavaScript. But in JavaScript, while "\xba" is a > special character, "\xb" is synonymous with "xb". > "\xb

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Steven D'Aprano
On Mon, 10 Aug 2009 00:57:18 -0700, Douglas Alan wrote: > On Aug 10, 2:10 am, Steven D'Aprano > >> I've never had any errors caused by this. > > But you've seen an error caused by this, in this very discussion. I.e., > "foo\xbar". Your complaint is that "invalid" escapes like \y resolve to a l

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Steven D'Aprano
On Mon, 10 Aug 2009 00:37:33 -0700, Carl Banks wrote: > On Aug 9, 11:10 pm, Steven D'Aprano > wrote: >> On Sun, 09 Aug 2009 18:34:14 -0700, Carl Banks wrote: >> >> Why should a backslash in a string literal be an error? >> >> > Because the behavior of \ in a string is context-dependent, which >>

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 2:10 am, Steven D'Aprano > I've never had any errors caused by this. But you've seen an error caused by this, in this very discussion. I.e., "foo\xbar". "\xba" isn't an escape sequence in any other language that I've used, which is one reason I made this error... Oh, wait a minute --

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Carl Banks
On Aug 9, 11:10 pm, Steven D'Aprano wrote: > On Sun, 09 Aug 2009 18:34:14 -0700, Carl Banks wrote: > >> Why should a backslash in a string literal be an error? > > > Because the behavior of \ in a string is context-dependent, which means > > a reader can't know if \ is a literal character or escap

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 2:03 am, Steven D'Aprano wrote: > On Sun, 09 Aug 2009 17:56:55 -0700, Douglas Alan wrote: > > Because in Python, if my friend sees the string "foo\xbar\n", he has no > > idea whether the "\x" is an escape sequence, or if it is just the > > characters "\x", unless he looks it up in the

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Steven D'Aprano
On Sun, 09 Aug 2009 23:03:14 -0700, John Nagle wrote: > if another escape character ever has to be > added to the language, that may change the semantics of previously > correct strings. And that's the only argument in favour of prohibiting non-special backslash sequences I've seen yet that is e

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Steven D'Aprano
On Sun, 09 Aug 2009 18:34:14 -0700, Carl Banks wrote: >> Why should a backslash in a string literal be an error? > > Because the behavior of \ in a string is context-dependent, which means > a reader can't know if \ is a literal character or escape character > without knowing the context, and it

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Steven D'Aprano
On Sun, 09 Aug 2009 17:56:55 -0700, Douglas Alan wrote: > Steven D'Aprano wrote: > >> Why should a backslash in a string literal be an error? > > Because in Python, if my friend sees the string "foo\xbar\n", he has no > idea whether the "\x" is an escape sequence, or if it is just the > characte

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread John Nagle
Carl Banks wrote: IOW it's an error-prone mess. It would be better if Python (like C) treated \ consistently as an escape character. (And in raw strings, consistently as a literal.) Agreed. For one thing, if another escape character ever has to be added to the language, that may change th

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Douglas Alan
On Aug 9, 8:06 pm, Steven D'Aprano wrote: > while the behaviour your > friend wants is "treat a backslash as an error, except for these > exceptions". Besides, can't all error situations be described as, "treat the error situation as an error, except for the exception of when the situation isn't

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Carl Banks
On Aug 9, 5:06 pm, Steven D'Aprano wrote: > On Sun, 09 Aug 2009 12:26:54 -0700, Douglas Alan wrote: > > A friend of mine is just learning Python, and he's a bit tweaked about > > how unrecognized escape sequences are treated in Python. > ... > > In any case, I think my friend should mellow out a b

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Douglas Alan
Steven D'Aprano wrote: > Why should a backslash in a string literal be an error? Because in Python, if my friend sees the string "foo\xbar\n", he has no idea whether the "\x" is an escape sequence, or if it is just the characters "\x", unless he looks it up in the manual, or tries it out in the R

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Steven D'Aprano
On Sun, 09 Aug 2009 12:26:54 -0700, Douglas Alan wrote: > A friend of mine is just learning Python, and he's a bit tweaked about > how unrecognized escape sequences are treated in Python. ... > In any case, I think my friend should mellow out a bit, but we both > consider this something of a wart.

Unrecognized escape sequences in string literals

2009-08-09 Thread Douglas Alan
A friend of mine is just learning Python, and he's a bit tweaked about how unrecognized escape sequences are treated in Python. This is from the Python 3.0 reference manual: Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left