1

For example, convert the string 'ZeroDivisionError' to the Python class ZeroDivisionError.

One obvious way of doing it is by using an if-else structure, but it is not feasible to do it for all the exceptions present in Python 3.

How do I do this?

2
  • Why would you need to do that? If you need the exception object, do not catch it, or rethrow it after cathing. Commented Mar 26, 2020 at 6:50
  • I need to extract the underlying Python exception thrown by a wrapped Exception class. Commented Mar 26, 2020 at 7:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.