On Thu, Aug 8, 2019 at 8:58 AM <raymond.hettin...@gmail.com> wrote:
>
> For me, these warnings are continuing to arise almost daily.  See two recent 
> examples below.  In both cases, the code previously had always worked without 
> complaint.
>
> ----- Example from yesterday's class ----
>
> ''' How old-style formatting works with positional placeholders
>
> print('The answer is %d today, but was %d yesterday' % (new, old))
>                                          \--------------------o
>                       \------------------------------------o
> '''
>
> SyntaxWarning: invalid escape sequence \-

I've no idea why this is even a string literal, but if it absolutely
has to be, then you could use a character other than backslash.

> ----- Example from today's class ----
>
> # Cut and pasted from:
> # https://en.wikipedia.org/wiki/VCard#vCard_2.1
> vcard = '''
> ...
> LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:100 Waters Edge=0D=
>  =0ABaytown\, LA 30314=0D=0AUnited States of America
> ...
> '''
>
> SyntaxWarning: invalid escape sequence \,

When you take a text string and create a string literal to represent
it, sometimes you have to modify it to become syntactically valid.
This is exactly the sort of thing that SHOULD be being warned about,
because it's sometimes going to work and sometimes not, depending on
the exact data you're working with. Please don't teach people the
habit of pretending that the backslash isn't significant.

If the warning were changed to be silent for 3.8, what would you do
differently? How would having extra time to solve this problem help
you?

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/WCNY3C7VBLCP5RDKKVMMEMN7R26GK2FI/

Reply via email to