On Wed, Oct 10, 2012 at 8:08 PM, Steven D'Aprano
On 11/10/12 07:08, Mike Graham wrote:
On Wed, Oct 10, 2012 at 3:46 PM, Antoine Pitrou
wrote: On Wed, 10 Oct 2012 15:36:08 -0400 Mike Graham
wrote: The literal"\c" should be an error
Who says so? My bash shell disagrees with you:
Frankly, I don't look to bash for sensible language design advice. I think concepts like "In the face of ambiguity, refuse the temptation to guess" guides how we should see the decision here. "Backslash is for escape sequences except when it's not" seemed like an obviously-misfortunate thing to me. I'm truly perplexed people see it as a feature they're eager to use, but I guess I should learn something from that.
Regular expressions are difficult if you're remembering which escape sequences exist and are easy if you're using raw string literals.
Just because some people find it hard to remember doesn't mean that it should be an error *not* to use raw strings.
I didn't say that it should be an error not to use raw strings. I was saying that the implication that this suggestion makes constructing regex strings hard is silly and mentioning the thing that makes them easy. I'm not suggesting that you shouldn't be able to use normal string literals. Antoine went on to point out that things like "\t" worked in regex strings. This is an unrelated feature that I never suggested altering. In that case, a tab character in your string is regarded like \t. This behavior would remain. I think four string escapes have been added since versions of Python I was aware of. Writing code like "ab\c" seems seedy in light of that Mike