I sometimes need to use multi-line strings, but in a nested block. This works, but the readability is really poor:
CONDITION1 = CONDITION2 = CONDITION3 = True
if CONDITION1:
if CONDITION2:
s = """jkljkj
dfkjslfds
sqjdlqkj"""
elif CONDITION3:
s = """azeazea
azeoiuaez
azeytzae
azetzae"""
Using:
if CONDITION1:
if CONDITION2:
s = """jkljkj
dfkjslfds
sqjdlqkj"""
(as suggested in Pythonic way to create a long multi-line string) is not an option because the string s
would be:
jkljkj
dfkjslfds
sqjdlqkj
with unwanted left spaces.
Question: how to use multi-line strings in nested blocks with a good readability?