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.

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
"""

Thanks tonyjv, your code works great. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.