0

Hello friends, I have a small problem with printing/getting exceptions in 3.1 version.

My code is:

try:
    # bla bla...
except Exception, e: # here I got error message "Invalid Syntax" in the comma
    self.setError(e)
    return False

What is the correct syntax in python 3.1 to get the exception message ?
Thanks.

Edited by Krstevski: n/a

2
Contributors
2
Replies
7
Views
7 Years
Discussion Span
Last Post by Krstevski
0

Your code is not in context but this seems to function normally for me in Python 3.1

def fun():
    try:
        fdjalsd
        # bla bla...
    except Exception as e: # here I got error message "Invalid Syntax" in the comma
        print('Handler, error:',e)
        return False

print(fun())
"""Output:
Handler, error: global name 'fdjalsd' is not defined
False
"""
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.