interpy
interpy copied to clipboard
Parsing fails when using implicit string concatenation
This concatenation style is valid and commonly use for multiline strings.
x = (
"foo"
"bar"
)
print x
output:
foobar
However it breaks when a variable interpolation is added:
# coding: interpy
a = 5
x = (
"foo #{a}"
"bar"
)
print x
output:
File "test.py", line 6
"bar"
^
SyntaxError: invalid syntax
I expected the output:
foo5bar
Since the bytecode generation converts the interpolation to addition, this would certainly seem to fail.
The code above is converted to:
x = (
"foo " + str(a)
"bar"
)
This sounds like a very common pitfall.
@PrashntS I would agree. I stopped using the library for that reason.