1

In the following code snippet, I get the response as -

__main__.CheckSumNotMatched: ('Kirti matches with - ', 'Kirti', ' . They are same.')

class CheckSumNotMatched(Exception):
    """Raised when the remote file's checksum doesn't match with local file checksum"""
    pass

def test(name):
    try:
        if name=="Kirti":
            error_msg = 'Kirti matches with - ', name, '. They are same. '
            raise CheckSumNotMatched(error_msg)
    except CheckSumNotMatched as csnm:
        logger.error(csnm)


if __name__ == "__main__":
    test("Kirti")

I want the response as - __main__.CheckSumNotMatched: Kirti matches with - Kirti. They are same.

I don't want ( and ' in the response. What should be the right way to do that?

1 Answer 1

1

you can replace

error_msg = 'Kirti matches with - ', name, '. They are same. '

with

error_msg = 'Kirti matches with - ' + name + '. They are same. '
Sign up to request clarification or add additional context in comments.

1 Comment

+ is a string concatenation operator in python while comma is a tuple operator. Previously error message was a tuple and not a string that's why there were brackets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.