Posts: 4,610
Threads: 1,483
Joined: Sep 2016
i have been putting comments in the triple-quoted string at the beginning of modules and functions. this was the source of some errors that did not say what line number. the error was putting backslash followed by "x[0-9a-f][0-9a-f]" as part of a comment about what backslash-X codes can be decoded by the function. but since these were in a real string, python was really parsing it all and doing its own backslash-X decoding. nice that it made me spend a half hour figuring this out because it would not tell me what line number.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,610
Threads: 1,483
Joined: Sep 2016
nope, try this extreme simple case that has the issue in python2. i still need to figure out the minimal case for python3, which works for this small one.
"""\x[0-9a-f][0-9a-f]"""
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,610
Threads: 1,483
Joined: Sep 2016
i gotta go read up on what all r'' does.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,610
Threads: 1,483
Joined: Sep 2016
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,610
Threads: 1,483
Joined: Sep 2016
Nov-30-2017, 01:20 AM
(This post was last modified: Nov-30-2017, 01:20 AM by Skaperen.)
is there any reason
not to do this (raw strings) for that first comment string, or any comment string, just as a matter of course everywhere including where it there is no need because there are no backslash sequences at all?
so if you need to assign a string of exactly one backslash to a variable named b, which would you use?
b = r'\' #1
b = '\\' #2
b = '\\'[0] #3
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.