This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Aditya Shankar
Recipients Aditya Shankar
Date 2019-04-14.13:58:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555250307.08.0.914630498101.issue36628@roundup.psfhosted.org>
In-reply-to
Content
Problem: multiline strings are a pain to represent (other than of-course in docstrings), representing a multiline string inside a function looks something like this -

def foo():
    # some code
    ...
    ...
    # some code
    text = """abc meta alpha chronos
dudes uptomes this text
is nonsense"""
    return somethingwith(text)

or

def foo():
    # some code
    ...
    ...
    # some code
    text = "\n".join(["abc meta alpha chronos",
                      "dudes uptomes this text",
                      "is nonsense"])
    return somethingwith(text)

an enhancement would be - 

def foo():
    # some code
    ...
    ...
    # some code
    text = i"""
            abc meta alpha chronos
            dudes uptomes this text
            is nonsense
            """
    return somethingwith(text)
i.e. all initial spaces are not considered as a part of the string in each ine

for example while throwing an exception -
def foo(bad_param):
    ...
    try:
        some_function_on(bad_param)
    except someException:
        throw(fi"""
                you cant do that because, and I'm gonna explain
                this in a paragraph of text with this {variable}
                because it explains things more clearly, also
                here is the {bad_param}
                """)
    ...
which is far neater than -

def foo(bad_param):
    ...
    try:
        some_function_on(bad_param)
    except someException:
        throw(f"""you cant do that because, and I'm gonna explain
this in a paragraph of text with this {variable}
because it explains things more clearly, also
here is the {bad_param}""")
    ...

pros:
    - represented code is closer to output text
    - implementation should not be too hard
History
Date User Action Args
2019-04-14 13:58:27Aditya Shankarsetrecipients: + Aditya Shankar
2019-04-14 13:58:27Aditya Shankarsetmessageid: <1555250307.08.0.914630498101.issue36628@roundup.psfhosted.org>
2019-04-14 13:58:27Aditya Shankarlinkissue36628 messages
2019-04-14 13:58:26Aditya Shankarcreate