interpy icon indicating copy to clipboard operation
interpy copied to clipboard

Parsing fails when file docstring uses double quotes

Open tedmiston opened this issue 9 years ago • 0 comments

For example, running this file:

# coding: interpy

"""
File docstring.
"""

food = 'tacos'
print "my favorite food is #{food}"

result:

File "test.py", line 3 """ ^ IndentationError: unexpected indent

Though changing double quotes to single quotes will pass:

# coding: interpy

'''
File docstring.
'''

food = 'tacos'
print "my favorite food is #{food}"

result:

my favorite food is tacos

But this change is non-optimal because we should use double quotes per PEP 257:

For consistency, always use """triple double quotes""" around docstrings. Use r"""raw triple double quotes""" if you use any backslashes in your docstrings. For Unicode docstrings, use u"""Unicode triple-quoted strings""" .

I understand this is not necessarily a trivial change because you still must handle triple double quoted strings used in code properly. For example:

print """\
a
#{food}
b"""

result:

a tacos b

tedmiston avatar Nov 17 '15 04:11 tedmiston