Hi all, I am new to programming and python and had a question. I hope I articulate this well enough so here it goes... I was following along on a thread on this mailing list discussing how to test file I/O operations. In one of the suggested solutions the following code was used:
def _open_as_stringio(self, filename): filelike = StringIO(self.filecontents[filename]) real_close = filelike.close def wrapped_close(): self.filecontents[filename] = filelike.getvalue() real_close() filelike.close = wrapped_close return filelike In trying to understand the logic behind the code for my own edification, I was wondering what is the reasoning of defining a function in side another function (for lack of a better phrase)? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor