[Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes? (original) (raw)

Ezio Melotti ezio.melotti at gmail.com
Tue Feb 24 07:23:21 CET 2015


Hi,

On Mon, Feb 23, 2015 at 9:58 PM, Joao S. O. Bueno <jsbueno at python.org.br> wrote:

On 23 February 2015 at 16:47, Antoine Pitrou <solipsis at pitrou.net> wrote:

On Mon, 23 Feb 2015 09:29:09 -0800 Guido van Rossum <guido at python.org> wrote:

On Mon, Feb 23, 2015 at 9:01 AM, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 02/23/2015 08:12 AM, Brett Cannon wrote: > > On Mon Feb 23 2015 at 10:55:23 AM Chris Angelico wrote: > > >> Is it at all possible for this to be introduced in the 2.x line [...] > > > > Starts with a minor version. > > Isn't there a -3 switch or something like that in 2.7.x to trigger > warnings/errors to help port to 3.x? Seems like this > kind of warning could go there. > If we agree it will be a syntax error in 3.x eventually. That sounds frankly like a pedantic change. The real problem there, even motivating the request, seems to be new users in Windows platforms using "" as file path separator. That happens all the time, and is this use case that should possibly be addressed here - maybe something as simple as adding a couple of paragraphs to different places in the documentation could mitigate the issue. (in contrast to make a tons of otherwise valid code to become deprecated in a couple releases).

Note that in the introduction page of the tutorial0, there is already the following snippet:

""" If you don’t want characters prefaced by \ to be interpreted as special characters, you can use raw strings by adding an r before the first quote:

print('C:\some\name') # here \n means newline! C:\some ame print(r'C:\some\name') # note the r before the quote C:\some\name """"

Best Regards, Ezio Melotti

Regards Antoine.



More information about the Python-Dev mailing list