class MyBad: def __init__(self, file, line): self.file = file self.line = line def display(self): print self.file * 2 def parser(): raise MyBad('spam.txt', 5) try: parser() except MyBad, X: print X.file, X.line X.display()