Is there a way to execute the try and return the body of the error as a variable?
try
i.e.
var = '' try: error generating code except: var = exception_body
Yes, use as except syntax:
as
except
try: raise Exception("hello world") except Exception as x: print(x)
In earlier versions of Python, this would be written except Exception, x: which you may see from time to time.
except Exception, x:
Source: https://habr.com/ru/post/906229/More articles:Use jQuery to check if an element has a border? - javascriptChange .htaccess with PHP - phpRuby file list excludes folder - ruby ββ| fooobar.comStandard (or free) POSIX COS interface control library - cWhy does this Google close line look like this? - javascriptWhy does STDERR output from Ruby happen before STDOUT exits when redirecting? - ruby ββ| fooobar.comHow to enable STDOUT.sync in ruby ββfrom the command line - ruby ββ| fooobar.comImpact of web.config and app.config changes - c #Need help improving syntax markup performance PowerShell script - performanceMore advanced syntax coloring in emacs for Python - pythonAll Articles