There is a fix () function, as an auxiliary function for the output function, which writes lines to a text file.
def fix(line): """ returns the corrected line, with all apostrophes prefixed by an escape character >>> fix('DOUG\'S') 'DOUG\\\'S' """ if '\'' in line: return line.replace('\'', '\\\'') return line
Turning on the doctrine, I get the following error:
Failed example: fix('DOUG'S') Exception raised: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1254, in __run compileflags, 1) in test.globs File "<doctest convert.fix[0]>", line 1 fix('DOUG'S') ^
No matter what combination I and I use, the teaching does not seem to want to work, although the function itself works fine. You have a suspicion that this is the result of the fact that the teaching is in block commentary, but any tips to eliminate it.
source share