Unrecognized escape sequences in string literals

MRAB python at mrabarnett.plus.com
Wed Aug 12 19:40:03 EDT 2009


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
>> <ste... at REMOVE.THIS.cybersource.com.au> 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 explicitly forbidden is permitted"
>> No, it doesn't. It boils down to whether a language should:
>>
>> (1) Try it's best to detect errors as early as possible, especially when
>> the cost of doing so is low.
> 
> You are making an unjustified assumption: \y is not an error. It is only 
> an error if you think that anything not explicitly permitted is forbidden.
> 
> While I'm amused that you've made my own point for me, I'm less amused 
> that you seem to be totally incapable of seeing past your parochial 
> language assumptions, even when those assumptions are explicitly pointed 
> out to you. Am I wasting my time engaging you in discussion? 
> 
> There's a lot more I could say, but time is short, so let me just 
> summarise:
> 
> I disagree with nearly everything you say in this post. I think that a 
> few points you make have some validity, but the vast majority are based 
> on a superficial and confused understanding of language design 
> principles. (I won't justify that claim now, perhaps later, time 
> permitting.) Nevertheless, I think that your ultimate wish -- for \y etc 
> to be considered an error -- is a reasonable design choice, given your 
> assumptions. But it's not the only reasonable design choice, and Bash has 
> made a different choice, and Python has made yet a third reasonable 
> choice, and Pascal made yet a fourth reasonable choice.
> 
IHMO, it would've been simpler in the long run to say that backslash
followed by one of [0-9A-Za-z] is an escape sequence, backslash followed
by newline is ignored, and backslash followed by anything else is that
something. That way there would be a way to introduce additional escape
sequences without breaking existing code.



More information about the Python-list mailing list