On Wed, Jun 17, 2015 at 12:49:38PM +0000, David Aldrich wrote: > Hi > > I have a function that compares a set of files with a reference set of > files. All files are compared and then, if any differences were > found, an exception is raised: [...] > I would like to pass back to the caller a list of the files that > failed. How would I include that list in the exception object?
Others have already answered your question, but I'm completely with Alan on this one: don't do this. Have your function return a list of differences. If there are no differences, return an empty list. The caller then decides what to do: diffs = checkfiles() if diffs: for fname in diffs: print("file name %s is different" % fname) repair_file(fname) else: raise NoDifferencesError( "expected some differences, but didn't find any" ) -- Steve _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor