Skip to content

Instantly share code, notes, and snippets.

@harikt
Created July 25, 2014 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/d8f2afc634771f469a42 to your computer and use it in GitHub Desktop.
Save harikt/d8f2afc634771f469a42 to your computer and use it in GitHub Desktop.
How to make the exception string without new line character ?
import sys, traceback
def func1():
try:
raise Exception
except:
# print (" %s " % sys.exc_info()[0])
exc_type, exc_value, exc_traceback = sys.exc_info()
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
print ''.join(line.strip() + ' ' for line in lines)
print " list "
print traceback.extract_tb(exc_traceback, 3)
print " Something awesome "
print traceback.format_exc()
func1()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment