On Thu, Aug 8, 2019 at 8:58 AM <raymond.hettinger@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